CF456B Fedya and Maths 找规律
http://codeforces.com/contest/456/problem/B
CF#260 div2 B Fedya and Maths
Codeforces Round #260
B. Fedya and Maths
time limit per test
1 secondmemory limit per test
256 megabytesinput
standard inputoutput
standard outputFedya studies in a gymnasium. Fedya's maths hometask is to calculate the following expression: for given value of n. Fedya managed to complete the task. Can you? Note that given number n can be extremely large (e.g. it can exceed any integer type of your programming language). Input
The single line contains a single integer n (0 ≤ n ≤ 10105). The number doesn't contain any leading zeroes. Output
Print the value of the expression without leading zeros. Sample test(s)
Input
4 Output
4 Input
124356983594583453458888889 Output
0 Note
Operation x mod y means taking remainder after division x by y. Note to the first sample: |
题解:
打表找规律,发现输入是4的倍数就出4,否则出0。
而4的倍数只用看最后两位,怕了。
1 //#pragma comment(linker, "/STACK:102400000,102400000") 2 #include<cstdio> 3 #include<cmath> 4 #include<iostream> 5 #include<cstring> 6 #include<algorithm> 7 #include<cmath> 8 #include<map> 9 #include<set> 10 #include<stack> 11 #include<queue> 12 using namespace std; 13 #define ll long long 14 #define usint unsigned int 15 #define mz(array) memset(array, 0, sizeof(array)) 16 #define minf(array) memset(array, 0x3f, sizeof(array)) 17 #define REP(i,n) for(i=0;i<(n);i++) 18 #define FOR(i,x,n) for(i=(x);i<=(n);i++) 19 #define RD(x) scanf("%d",&x) 20 #define RD2(x,y) scanf("%d%d",&x,&y) 21 #define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z) 22 #define WN(x) printf("%d\n",x); 23 #define RE freopen("D.in","r",stdin) 24 #define WE freopen("1biao.out","w",stdout) 25 26 int main() { 27 //RE; 28 ll n=0; 29 char c,prec,preprec; 30 while(scanf("%c",&c)!=EOF && c>='0' && c<='9') { 31 preprec=prec; 32 prec=c; 33 n++; 34 } 35 //printf("%c,%c,%c\n",c,prec,preprec); 36 ll t; 37 if(n>1) t=(preprec-'0')*10+(prec-'0'); 38 else t=prec-'0'; 39 if(t%4==0)puts("4"); 40 else puts("0"); 41 return 0; 42 }