http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4091

C++版本一

题解:高精度

1、对原数循环除以2;

2、添加每次的结果到ans数组;

3、数据范围二进制大概2的3400次;

4、代码不是最优(比如如果原数已经0,可以直接退出);

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int ans,cnt,flag,temp,sum;
int a[N],c[N];
char str[N];
struct node{};
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);scanf("%d",&t);while(t--){//scanf("%d",&n);cin>>str;int len=strlen(str);memset(c,0,sizeof(c));memset(a,0,sizeof(a));for(int i=1;i<=len;i++){a[i]=str[len-i]-'0';}c[0]=1;for(int i=0;i<3400+10;i++){int now=0;for(int j=len;j>=1;j--){a[j]+=now*10;now=0;if(a[j]%2==1){now=1;}a[j]/=2;}int limit=max(len,c[0])+100;for(int j=1;j<=limit;j++){c[j]+=a[j];if(c[j]>=10){c[j+1]+=c[j]/10;c[j]%=10;}if(c[j]){c[0]=max(c[0],j);}}}for(int i=c[0];i>=1;i--){cout<<c[i];}cout<<endl;}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}

Python版本一

t = int(input())
while t > 0:n = int(input())ans = int(0)t -= 1while n > 0:n //= 2ans += nprint(ans)

Even Number Theory相关推荐

  1. Number Theory Problem(The 2016 ACM-ICPC Asia China-Final Contest 找规律)

    题目: Mr. Panda is one of the top specialists on number theory all over the world. Now Mr. Panda is in ...

  2. NUMTRYE - Number Theory (Easy)

    NUMTRYE - Number Theory (Easy) Hard 版本就是用 pollard_rho 分解质因子. f(n)=∏(pi2ei+1+1)f(n) = \prod(p_i ^{2e_ ...

  3. Codeforces Round #628 (Div. 2) E. Ehab‘s REAL Number Theory Problem 巧妙的质因子建图

    传送门 文章目录 题意: 思路: 题意: 给你nnn个数,每个数的因子个数不超过777个,选出最少的数使其乘积为平方数. n≤1e5n\le 1e5n≤1e5 思路: 由于因子不超过777个,所以由约 ...

  4. 2016级算法第二次上机-F.ModricWang's Number Theory II

    891 ModricWang's Number Theory II 思路 使得序列的最大公约数不为1,就是大于等于2,就是找到一个大于等于2的数,它能够整除序列中的所有数. 考虑使得一个数d整除数组中 ...

  5. Segment 2:Introduction Number Theory——Fermat and Euler【费马定理和欧拉定理】

    Segment 2:Introduction Number Theory--Fermat and Euler[费马定理和欧拉定理] 这是整个数论简介的内容,下面是这个的主目录,其链接为:https:/ ...

  6. Elliptic Curves Number Theory And Cryptography——pairing learning

    <Elliptic Curves Number Theory And Cryptography 2n>中Example 11.5, magma脚本: clear; q:=7; Fq:=GF ...

  7. concrete maths ch4 number theory

    ch4 number theory 数论研究正数的性质 1.整除 gcd lcm 扩展欧几里得. 整除求和\(\sum_{n|m}\)的几个公式.ch2的知识会很有用. 2.质数 Fundamenta ...

  8. 图论 + 数论 ---- CF1325E E. Ehab‘s REAL Number Theory Problem (约数个数 + 枚举 + bfs找最小环)[从图结构优化搜索]

    题目链接 题目大意: 给你nnn个数,每个数保证约数个数不超过777个.问你从中选出若 干个数的乘积是完全平方数,最少要选择多少个数?,不存在输出-1. 题目思路: 1.每个数约数不超过7个→\rig ...

  9. FZU 2297 Number theory【线段树/单点更新/思维】

    Given a integers x = 1, you have to apply Q (Q ≤ 100000) operations: Multiply, Divide. Input First l ...

  10. BZOJ 1114 Number theory(莫比乌斯反演+预处理)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=71738 题意:给你一个整数序列a1, a2, a3, ... , ...

最新文章

  1. ArrayList 集合
  2. 吴敏霞(为奥运冠军名字作诗)
  3. rabbitmq集群报错
  4. Keepalived+nginx造成流量异常
  5. matlab 读取WAV文件
  6. Linux入门——文件管理
  7. c语言左移15位,关于c语言中左移右移运算符的问题
  8. Git 内部原理图解——对象、分支以及如何从零开始建仓库
  9. asp 可否压缩_怎样用ASP压缩文件
  10. Android系统性能优化(54)---Android性能分析专题
  11. WebLogic在Linux环境下安装
  12. 勒索病毒运营团伙的运作流程
  13. set的erase()函数
  14. 使用apktool来解包和重新打包
  15. 短视频秒播优化实践(一)
  16. 区块链应用如何实现资金盘分红
  17. 华为模拟器eNSP - HCIP - OSPF的Totally STUB 、Totally NSSA综合实验
  18. Raspberry Pi 树莓派查看CPU温度
  19. 厦门大学-机器学习-苏松志
  20. 怎样转换WPS格式,WPS怎么转换PPT格式

热门文章

  1. url充定向 html转义,html、javascript、url特殊字符的转义诠释及使用方法详解
  2. scanf 接收 空格 输入_【C语言】- printf 和scanf 函数详解!
  3. 6 MyBatis基于Mapper接口CURD
  4. 微型计算机内存为8m,通常说一台微机的内存容量为8M,指的是_______。
  5. android调用另一app的xml,Android 7.0+调用其他App打开文件
  6. l2的最优回归_【机器学习】逻辑回归(非常详细)
  7. 三十五、深入Java中的泛型(下篇)
  8. 一阶暂态电路三要素法和三种响应
  9. excel中的vlookup函数
  10. 全网首个OpenPrompt尝鲜报告:Prompt研究者必备实验利器