51NOD 1491 黄金系统 && Codeforces 458 A. Golden System(斐波那契数列 + 找规律)
来源:互联网 发布:如何使淘宝排名靠前 编辑:程序博客网 时间:2024/05/22 15:05
传送门
现在给出两个黄金系统下面的数字,请比较他们的大小。
Input
单组测试数据。
第一行有一个字符串
第二行有一个字符串
他们都是非空串,可能有前导
Output
如果
如果
如果
Input示例
00100
11
Output示例
=
解题思路:
其实通过样例我们可以发现这样一个规律:
我们就可以,通过将所有
就加加,如果是
了。因为中间转移的时候 会爆
就最后判断 一下
/**2016 - 08 - 19 下午Author: ITAKMotto:今日的我要超越昨日的我,明日的我要胜过今日的我,以创作出更好的代码为目标,不断地超越自己。**/#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <vector>#include <queue>#include <algorithm>#include <set>using namespace std;typedef long long LL;typedef unsigned long long ULL;const int INF = 1e9+5;const int MAXN = 1e5+5;const int MOD = 1e9+7;const double eps = 1e-7;const double PI = acos(-1);using namespace std;LL Scan_LL()///输入外挂{ LL res=0,ch,flag=0; if((ch=getchar())=='-') flag=1; else if(ch>='0'&&ch<='9') res=ch-'0'; while((ch=getchar())>='0'&&ch<='9') res=res*10+ch-'0'; return flag?-res:res;}int Scan_Int()///输入外挂{ int res=0,ch,flag=0; if((ch=getchar())=='-') flag=1; else if(ch>='0'&&ch<='9') res=ch-'0'; while((ch=getchar())>='0'&&ch<='9') res=res*10+ch-'0'; return flag?-res:res;}void Out(LL a)///输出外挂{ if(a>9) Out(a/10); putchar(a%10+'0');}char a[MAXN], b[MAXN];double f[MAXN];int main(){ while(~scanf("%s%s",a,b)) { int lena = strlen(a); int lenb = strlen(b); memset(f, 0, sizeof(f)); for(int i=0; i<lena; i++) if(a[i] == '1') f[lena-i-1]++; for(int i=0; i<lenb; i++) if(b[i] == '1') f[lenb-i-1]--; int tmp = max(lena, lenb); for(int i=tmp-1; i>=2; i--) { f[i-1] += f[i]; f[i-2] += f[i]; } if(!f[0] && !f[1]) { puts("="); continue; } double ans = (sqrt(5.0)+1)*0.5*f[1] + f[0]; if(ans < 0.0) puts("<"); else puts(">"); } return 0;}
0 0
- 51NOD 1491 黄金系统 && Codeforces 458 A. Golden System(斐波那契数列 + 找规律)
- 51nod 1491|CodeForces 458A Golden System(数论 )
- 51nod-斐波那契表示(找规律)
- Codeforces Round #382 (Div. 2) -- C. Tennis Championship (数学找规律 -- 斐波那契数列)
- 51nod 1350 斐波那契表示(打表+找规律)
- hpuoj【1444】斐波那契数列&& 【找规律】
- Codeforces 458A Golden System
- Codeforces 458A Golden System
- HDU 5620 KK's Steel(找规律,斐波那契数列的应用)
- 找规律,数学(巨大的斐波那契数列,uva 11582)
- Codeforces 458A/51nod 1491 黄金系统【思维】好题~
- 51nod-1350 斐波那契表示(规律)
- 51nod 1350 斐波那契表示(规律)
- 【CodeForces】458A - Golden System(数论 & 模拟)
- HDU 4549 M斐波那契数列 (找规律+矩阵快速幂+数快速幂)
- hdu2516 取石子游戏-----找规律 必败点---斐波那契数列
- 斐波那契数列规律探索
- 51NOD 1350 斐波那契表示 规律+递归
- B/S 和 C/S
- Struts值栈与Ognl
- 单源最短路径算法-Dijkstra
- Java String类
- 写时拷贝的方式实现基本的String类
- 51NOD 1491 黄金系统 && Codeforces 458 A. Golden System(斐波那契数列 + 找规律)
- tHINKpHP认识---文件了解
- test
- Docker入门
- 【计算机网络-10】【第四章】网络层
- Android之蓝牙startDiscovery()搜索不到设备
- Java数组
- 关于JavaScript的定时器的基础和应用
- Visio2013使用注记