标签:
传送门
现在给出两个黄金系统下面的数字,请比较他们的大小。
Input
单组测试数据。
第一行有一个字符串
第二行有一个字符串
他们都是非空串,可能有前导
Output
如果
如果
如果
Input示例
00100
11
Output示例
=
解题思路:
其实通过样例我们可以发现这样一个规律:
我们就可以,通过将所有
就加加,如果是
了。因为中间转移的时候 会爆
就最后判断 一下
/**
2016 - 08 - 19 下午
Author: ITAK
Motto:
今日的我要超越昨日的我,明日的我要胜过今日的我,
以创作出更好的代码为目标,不断地超越自己。
**/
#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;
}
51NOD 1491 黄金系统 && Codeforces 458 A. Golden System(斐波那契数列 + 找规律)
标签:
原文地址:http://blog.csdn.net/qingshui23/article/details/52266534