51nod 1491|CodeForces 458A Golden System(数论 )
2016-09-04 13:52
417 查看
51nod 1491|CodeForces 458A
题目
有中文题目思路
看到q=5√+12就应该反应过来是斐波那契数列了,还学到了一个不等式q^n>q^0+q^1+q^2+…+q^(n-2),做法就是先合并同类项,然后从高位向低位反推,因为不等式的存在,num的某一项为2或者-2就可以直接输出了,若没退出,最后判断一下 q*num[1] + num[0] 。代码
#include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <cmath> #include <iostream> using namespace std ; typedef long long ll; char s1[100010]; char s2[100010]; int s3[100010]; int main() { double q = (sqrt(5)+1) / 2.0; scanf("%s",s1); scanf("%s",s2); int len1=strlen(s1); int len2=strlen(s2); int len=max(len1,len2); for(int i=len-1; i>=0; i--) { int t1,t2; if(i>=len1) t1=0; else t1=s1[len1-i-1]-'0'; if(i>=len2) t2=0; else t2=s2[len2-i-1]-'0'; s3[i]=t1-t2; } for(int i=len-1; i>=2; i--) { if(s3[i]>=2) { printf(">\n"); return 0; } else if(s3[i]<=-2) { printf("<\n"); return 0; } s3[i-1]+=s3[i]; s3[i-2]+=s3[i]; } if (s3[1]*q + s3[0] > 0) puts(">"); else if (s3[1]*q + s3[0] < 0) puts("<"); else puts("="); return 0 ; }
相关文章推荐
- 51nod 1491-黄金系统(数论->递推)
- [数论] 51Nod 1217 Minimum Modular & Codeforces 303C #183 (Div. 1) Minimum Modular
- Codeforces 458A/51nod 1491 黄金系统【思维】好题~
- 51NOD 1491 黄金系统 && Codeforces 458 A. Golden System(斐波那契数列 + 找规律)
- codeforces 27E - Number With The Given Amount Of Divisors (数论 dfs)
- codeforces 680C C. Bear and Prime 100(数论)
- Codeforces 711E 数论
- codeforces 468 B && 51nod 1557 两个集合
- 51Nod 1354 DP + 数论
- codeforces 498C C. Array and Operations(最大流+数论)
- Codeforces 235E Number Challenge 莫比乌斯反演+数论
- CodeForces - 376C Divisible by Seven(数论:同余定理)(找规律)
- CodeForces - 359C Prime Number(数论)
- 51nod 1799 思维 二分 数论 分块打表
- 51nod 1616 最小集合(数论)(枚举)
- 51nod--1135 原根 (数论)
- [数论] 51Nod 1189 阶乘分数
- CodeForces - 616E Sum of Remainders (数论)大数取余求和 好题
- CodeForces 628B(数论)
- CodeForces 623 B.Array GCD(数论+dp)