Codeforces Round #260 (Div. 2) B. Fedya and Maths
来源:互联网 发布:侧卧按键开关封装淘宝 编辑:程序博客网 时间:2024/06/06 11:39
这个题是找规律题,刚开始一看很蒙;
后来自己推了一下,1^n,2^n,3^n,4^n它们的个位数会随n的增加而循环变化,其中2和3的循环节是4;4的循环节是2;
这样就能推出它们的和MOD5的数是在0,0,0,4中循环,即判断一个数是否能被4整除,如果可以则输出4,否则输出0;
判断是否能被4整除:只需要判断这个数后两位是否能被4整除即可;
#include<cstdio>#include<cstring>#include<cmath>#include<climits>#include<cctype>#include<cstdlib>#include<iostream>#include<algorithm>#include<queue>#include<vector>#include<map>#include<set>#include<string>#include<stack>#define ll long long #define MAX 100010#define INF INT_MAX#define eps 1e-8using namespace std;char s[MAX];int main(){while (scanf("%s",s) != EOF){int len = strlen(s),a = 0;if(len == 1){a = a + s[len-1] - '0';}else{a = a*10 + s[len-2] - '0';a = a*10 + s[len-1] - '0'; }//printf("a = %d\n",a);if (a % 4 == 0) printf("%d\n",4);else printf("%d\n",0);}return 0;}
0 0
- Codeforces Round #260 (Div. 2) B. Fedya and Maths
- Codeforces Round #260 (Div. 2)B. Fedya and Maths
- Codeforces Round #260 (Div. 2) B Fedya and Maths
- Codeforces Round #260 (Div. 2) B. Fedya and Maths
- Codeforces Round #260 (Div. 2)B. Fedya and Maths
- Codeforces Round #260 (Div. 2) B. Fedya and Maths
- Codeforces Round #260 (Div. 2)B. Fedya and Maths
- Codeforces #260 (Div. 2) B. Fedya and Maths(数学:水题)
- Codeforces Round #260 (Div. 2) B. Fedya and Maths【超数范围的取模】
- Codeforces Round #260 (Div. 2) B. Fedya and Maths(循环节)
- Codeforces Round #260 (Div. 2) B. Fedya and Maths(循环结)
- Codeforces Round #260 (Div. 2) B. Fedya and Maths (数学规律)
- codeforces #260 B. Fedya and Maths(水)
- Codeforces 456B Fedya and Maths
- Codeforces 456B Fedya and Maths(数学)
- B. Fedya and Maths
- Codeforces Round #260 (Div. 2)456B - Fedya and Maths (找循环节,大数取模)那些用int的人运气真好,竟然没人去Hack
- CF 260 B. Fedya and Maths
- leetcode 刷题之路 54 Jump Game
- Codeforces Round #260 (Div. 2)A. Laptops
- sap les
- 后缀数组
- poj 2595 Treasure Exploration
- Codeforces Round #260 (Div. 2) B. Fedya and Maths
- 区别之守护进程 孤儿进程 僵尸进程
- jmeter使用2-springmvc request
- 25465413214654
- Backbone.js源码分析系列之Collection模块
- 黑马程序员--高新技术(内省)
- 是发个V大分还不
- Java中的Class类以及获取Class对象的三种方式
- Codeforces Round #260 (Div. 2) C. Boredom