1-N(1的总数)找规律
见:https://blog.csdn.net/dormousenone/article/details/75208903
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>//sprintf islower isupper
#include <cstdlib>//malloc exit strcat itoa system("cls")
#include <iostream>//pair
#include <fstream>//freopen("C:\\Users\\13606\\Desktop\\草稿.txt","r",stdin);
#include <bitset>
//#include <map>
//#include<unordered_map>
#include <vector>
#include <stack>
#include <set>
#include <string.h>//strstr substr
#include <string>
#include <time.h>//srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9;
#include <cmath>
#include <deque>
#include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less
#include <vector>//emplace_back
//#include <math.h>
//#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor
#include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare)
using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation
#define fo(a,b,c) for(register int a=b;a<=c;++a)
#define fr(a,b,c) for(register int a=b;a>=c;--a)
#define mem(a,b) memset(a,b,sizeof(a))
#define pr printf
#define sc scanf
#define ls rt<<1
#define rs rt<<1|1
typedef long long ll;
#define rint register int;
void swapp(int &a,int &b);
double fabss(double a);
int maxx(int a,int b);
int minn(int a,int b);
int Del_bit_1(int n);
int lowbit(int n);
int abss(int a);
//const long long INF=(1LL<<60);
const double E=2.718281828;
const double PI=acos(-1.0);
const int inf=(<<);
const double ESP=1e-;
const int mod=(int)1e9+;
const int N=(int)1e6+; ll ans[];
char s[N];
ll get(int l)
{
ll sum=;
for(int i=;i<=l;++i)
sum*=,sum+=s[i]-'';
return sum;
} int main()
{
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
ans[]=;
while(~sc("%s",s+))
{
int l=strlen(s+);
if(l>)
pr("83 1111111110\n");
else
{
ll t=get(l);
for(int i=;i<=;++i)
{
if(i==||t<ans[i+])
{
pr("%d %lld\n",i,ans[i]);
break;
}
}
}
}
return ;
} /**************************************************************************************/ int maxx(int a,int b)
{
return a>b?a:b;
} void swapp(int &a,int &b)
{
a^=b^=a^=b;
} int lowbit(int n)
{
return n&(-n);
} int Del_bit_1(int n)
{
return n&(n-);
} int abss(int a)
{
return a>?a:-a;
} double fabss(double a)
{
return a>?a:-a;
} int minn(int a,int b)
{
return a<b?a:b;
}
1-N(1的总数)找规律的更多相关文章
- LightOJ 13361336 - Sigma Function (找规律 + 唯一分解定理)
http://lightoj.com/volume_showproblem.php?problem=1336 Sigma Function Time Limit:2000MS Memory L ...
- HDU 3032 (SG打表找规律)
题意: 有n堆石子,alice先取,每次可以选择拿走一堆石子中的1~x(该堆石子总数) ,也可以选择将这堆石子分成任意的两堆.alice与bob轮流取,取走最后一个石子的人胜利. 思路: 因为数的范围 ...
- hdu 2604 Queuing dp找规律 然后矩阵快速幂。坑!!
http://acm.hdu.edu.cn/showproblem.php?pid=2604 这题居然O(9 * L)的dp过不了,TLE, 更重要的是找出规律后,O(n)递推也过不了,TLE,一定 ...
- 找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones
题目传送门 /* 找规律/贪心:ans = n - 01匹配的总数,水 */ #include <cstdio> #include <iostream> #include &l ...
- hdu 3951 - Coin Game(找规律)
这道题是有规律的博弈题目,,, 所以我们只需要找出规律来就ok了 牛人用sg函数暴力找规律,菜鸟手工模拟以求规律...[牢骚] if(m>=2) { if(n<=m) {first第一口就 ...
- HDU 5703 Desert 水题 找规律
已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这 ...
- hdu4952 Number Transformation (找规律)
2014多校 第八题 1008 2014 Multi-University Training Contest 8 4952 Number Transformation Number Transform ...
- CF456B Fedya and Maths 找规律
http://codeforces.com/contest/456/problem/B CF#260 div2 B Fedya and Maths Codeforces Round #260 B. F ...
- hdu 4731 2013成都赛区网络赛 找规律
题意:找字串中最长回文串的最小值的串 m=2的时候暴力打表找规律,打表可以用二进制枚举
- 找规律 Codeforces Round #290 (Div. 2) A. Fox And Snake
题目传送门 /* 水题 找规律输出 */ #include <cstdio> #include <iostream> #include <cstring> #inc ...
随机推荐
- Spring Cloud Eureka(四):Eureka 配置参数说明
Eureka Client 配置项(eureka.client.*) org.springframework.cloud.netflix.eureka.EurekaClientConfigBean 参 ...
- JavaWeb_(SSH)三大框架整合struts+hibernate+spring_Demo
三大框架整合 一.SSH导包 二.书写Spring 三.书写Struts 四.整合Spring与Struts 五.书写(与整合)Hibernate.引入c3p0连接池并使用hibernate模板 六. ...
- js动态往对象里边添加一项
第一种方法let obj ={"name":"tom","age":16}let key = "id";let valu ...
- react-redux学习初步总结
1.index.js文件中需要引入 a.React(把jsx编译到js需要调用一个函数, 这个函数在React叫React.createElement. 解答地址:https://segmentfau ...
- tkinter入门-布局方式pack(), grid(), place()
pack 转载于https://www.cnblogs.com/kongzhagen/p/6144588.html\ 1. 使用pack函数的时候,默认先使用放到上面的,然后依次从上向下排 2. 可接 ...
- LC 820. Short Encoding of Words
Given a list of words, we may encode it by writing a reference string S and a list of indexes A. For ...
- php如何开启gd2扩展
extension=php_gd2.dll 找到php的配置文件php.ini,搜索extension=php_gd2.dll,去掉前面的分号即可:如果没有直接添加这种情况适合于windows系统和编 ...
- Unity3D热更新之LuaFramework篇[05]--Lua脚本调用c#以及如何在Lua中使用Dotween
在上一篇文章 Unity3D热更新之LuaFramework篇[04]--自定义UI监听方法 中,我对LuaBehaviour脚本进行了扩展,添加了两个新的UI监听方法,也提到最好能单写一个脚本处理此 ...
- hive中case命令
- DP,数论————洛谷P4317 花神的数论题(求1~n二进制中1的个数和)
玄学代码(是洛谷题解里的一位dalao小粉兔写的) //数位DP(二进制)计算出f[i]为恰好有i个的方案数. //答案为∏(i^f[i]),快速幂解决. #include<bits/stdc+ ...