ZOJ4108 Fibonacci in the Pocket

 Ab two numbers are given to you ask Feibolaqi number and a column item to the second item of b is odd or even

Let's take a concept of parity constitute 察斐波拉契 series of cycles even Kiki Kiki Kiki even ...... even such a group of three

Then we were the first to determine ab a few number of cycles to keep on with a string and each character b is then converted to an integer corresponding to each digit is -48

With each number to be able to get 3 remainder Which one is the number of cycles in the

Then see below

(Simple push came out)

AC Code:

 1 #include<bits/stdc++.h>
 2 #define pi acos(-1)
 3 typedef long long ll;
 4 typedef unsigned long long ull;
 5 using namespace std;
 6 
 7 namespace io {
 8     const int SIZE = 1e7 + 10;
 9     char inbuff[SIZE];
10     char *l, *r;
11     inline void init() {
12         l = inbuff;
13         r = inbuff + fread(inbuff, 1, SIZE, stdin);
14     }
15     inline char gc() {
16         if (l == r) init();
17         return (l != r) ? *(l++) : EOF;
18     }
19     void read(int &x) {
20         x = 0; char ch = gc();
21         while(!isdigit(ch)) ch = gc();
22         while(isdigit(ch)) x = x * 10 + ch - '0', ch = gc();
23     }
24 } using io::read;
25 
26 bool cmp(const int &a, const int &b){
27     return a > b;
28 }
29 
30 int main(){
31     ios::sync_with_stdio(false);
32     int t;
33     cin>>t;
34     string a, b;
35     while (t--){
36         cin>>a>>b;
37         int sum1 = 0, sum2 = 0;
38         for (int i = 0; i < a.size(); i++)
39             sum1 += int(a[i]) - 48;
40         for (int i = 0; i < b.size(); i++)
41             sum2 += int(b[i]) - 48;
42         int tmp1 = sum1 % 3, tmp2 = sum2 % 3;
43         if ((tmp1 == 0 && tmp2 == 1) || (tmp1 == 1 && tmp2 == 1) ||
44             (tmp1 == 2 && tmp2 == 0) || (tmp1 == 2 && tmp2 == 2))
45             cout<<1<<endl;
46         else cout<<0<<endl;
47     }
48     return 0;
49 }

 

Guess you like

Origin www.cnblogs.com/Misuchii/p/10983803.html