CF memsql Start[c]UP 2.0 A

A. Golden System

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number

, in particular that q2 = q + 1, and she thinks it would make a good base for her new unique system. She called it "golden system". In golden system the number is a non-empty string containing 0's and 1's as digits. The decimal value of expressiona0a1...an equals to

.

Soon Piegirl found out that this system doesn't have same properties that integer base systems do and some operations can not be performed on it. She wasn't able to come up with a fast way of comparing two numbers. She is asking for your help.

Given two numbers written in golden system notation, determine which of them has larger decimal value.

Input

Input consists of two lines — one for each number. Each line contains non-empty string consisting of '0' and '1' characters. The length of each string does not exceed 100000.

Output

Print ">" if the first number is larger, "<" if it is smaller and "=" if they are equal.

Sample test(s)

input

1000 
111

output

<

input

00100 
11

output

=

input

110 
101

output

>

Note

In the first example first number equals to

, while second number is approximately1.6180339882 + 1.618033988 + 1 ≈ 5.236, which is clearly a bigger number.

In the second example numbers are equal. Each of them is  ≈ 2.618.

思路:最开始想推每一项的公式,不行,系数太大!后来想把前面的1全部转化为后面的1,发现这样的话也会2^100000太大!

后来发现如果一个字符串中出现的第一个1比另一个字符串中的第一个1高两位的话,就是这个串大,否则转化为后面的1(也就是第i位的1等于第i-1位的1和第i-2位的1)然后再逐位判断对多10^5。

处理时要把字符串反转,放在vector里面然后reverse(),竟然超时,换做直接字符串反转函数,AC 30ms!

 #include<cstdio>

 #include<iostream>

 #include<cmath>

 #include<stdlib.h>

 #include<vector>

 #include<cstring>

 #include<map>

 #include<algorithm>

 #include<string.h>

 #define M(a,b) memset(a,b,sizeof(a))

 #define INF 0x3f3f3f3f

 using namespace std;

 char a[],b[];

 int num[];

 vector<char> v1,v2;

 void strRev(char *s)

 {

     char temp, *end = s + strlen(s) - ;

     while( end > s)

     {

         temp = *s;

         *s = *end;

         *end = temp;

         --end;

         ++s;

     }

 }

 int main()

 {

     while(scanf("%s",a)==)

     {

         scanf("%s",b);

         int n = max(strlen(a),strlen(b));

         strRev(a);

         strRev(b);

         int strla = strlen(a);

         int strlb = strlen(b);

         int tem = strlen(a)-strlen(b);

         if(tem < )

         {

             for(int i = ;i<-tem;i++)

                 a[strla+i] = '';

         }

         else

         {

             for(int i = ;i<tem;i++)

                 b[strlb+i] = '';

         }

         /*for(int i = 0;i<n;i++) cout<<a[i];

         cout<<endl;

          for(int i = 0;i<n;i++) cout<<b[i];

         cout<<endl;*/

         for(int i = ;i<n;i++)

         {

             if(a[i] == '' && b[i] == '') num[i+] = ;

             else if(a[i] == '' && b[i] == '') num[i+] = ;

             else if(a[i] == '' && b[i] == '') num[i+] = ;

             else if(a[i] == '' && b[i] == '') num[i+] = -;

         }

         num[] = ;

         num[] = ;

         //for(int i = 0;i<n+2;i++) cout<<num[i];

         //cout<<endl;

         for(int i = n+;i>=;i--)

         {

             if(i==&&num[i]==) puts("=");

             if(num[i]==){puts(">"); break;}

             if(num[i]==-){puts("<"); break;}

             if(num[i] == ) continue;

             if(num[i] == )

             {

                 if(num[i-]==||num[i-]==) {puts(">"); break;}

                 if(num[i-]==-) num[i-]+=, num[i-]+=;

             }

             if(num[i] == -)

             {

                 if(num[i-]==||num[i-]==-) {puts("<"); break;}

                 if(num[i-]==) num[i-]-=, num[i-]-=;

             }

         }

     }

     return ;

 }

CF memsql Start[c]UP 2.0 A的更多相关文章

  1. CF memsql Start[c]UP 2.0 B

    CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...

  2. 【CF MEMSQL 3.0 A. Declined Finalists】

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  3. 【CF MEMSQL 3.0 E. Desk Disorder】

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  4. 【CF MEMSQL 3.0 D. Third Month Insanity】

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  5. 【CF MEMSQL 3.0 C. Pie Rules】

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  6. 【CF MEMSQL 3.0 B. Lazy Security Guard】

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  7. MemSQL Start[c]UP 2.0 - Round 1(无聊练手B题)

    http://codeforces.com/contest/452/problem/B   B. 4-point polyline time limit per test 2 seconds memo ...

  8. MemSQL Start[c]UP 2.0 - Round 2 - Online Round

    搞到凌晨4点一个没出,要gg了. A. Golden System http://codeforces.com/contest/458/problem/A #include<cstdio> ...

  9. MemSQL Start[c]UP 2.0 - Round 1

    A. Eevee http://codeforces.com/contest/452/problem/A 字符串水题 #include<cstdio> #include<cstrin ...

随机推荐

  1. bzoj-4514(网络流)

    题目链接: 4514: [Sdoi2016]数字配对 Description 有 n 种数字,第 i 种数字是 ai.有 bi 个,权值是 ci. 若两个数字 ai.aj 满足,ai 是 aj 的倍数 ...

  2. Java程序设计之整数分解

    题目:题目:将一个正整数分解质因数.例如:输入90,打印出90=2*3*3*5. 解题过程也很简单,下面直接上代码了: import java.util.ArrayList; import java. ...

  3. ES5基础之正则表达式01:初次见面

    1.正则初次见面 测试地址:https://regexper.com 第一个正则:匹配 2006-10-11 或 2006/10/11 var reg = /^\d{4}[-/]\d{2}[-/]\d ...

  4. 微信内嵌html5页面清楚缓存

    给每个js添加一个版本号,每次修改js后改变一下版本号,浏览器即可自动刷新不用手动清理缓存 <script src="<%=path%>/js/boss/kpi/redli ...

  5. 微信小程序入门正确姿势(一)

    [未经作者本人同意,请勿以任何形式转载] >>>前言 这是 [认真学编程] 系列的 第4篇 文章(微信小程序入门系列),欢迎点赞分享.写留言,这些都是对我最好的支持. 本系列适合有一 ...

  6. 《Java学习笔记(第8版)》学习指导

    <Java学习笔记(第8版)>学习指导 目录 图书简况 学习指导 第一章 Java平台概论 第二章 从JDK到IDE 第三章 基础语法 第四章 认识对象 第五章 对象封装 第六章 继承与多 ...

  7. 获取使用ClickOnce部署的应用程序的版本号

    引子 在编写使用ClickOnce部署的应用程序时,需要在程序的标题栏.软件变更记录.软件关于等页面读取显示当前的版本号. 之前很傻瓜的做法就是在Resource中维护一个string值,在使用到的地 ...

  8. Codeforces Canda Cup 2016

    A.B:模拟 C.构造下就行了 D.题意:n个参加ACM的队(n<=300000),每个队都有自己的初始气球数和重量,规定如果气球数>重量,那么此队就会飞起来,淘汰出局,你现在是第一组,你 ...

  9. Android Studio22-NDK-LLDB调试

    Android Studio2.2更好的支持NDK开发,并可以像开发java一样的DEBUG程序,不需要添加gradle-experimental插件,就可调试代码! 一,下载 NDK 和构建工具 要 ...

  10. JQuery对id中含有特殊字符的转义处理

    转载--http://www.jb51.net/article/41192.htm <div id="a[]">kkkkkk</div> <scrip ...