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 second memory limit per test
256 megabytes input
standard input output
standard output Fedya studies in a gymnasium. Fedya's maths hometask is to calculate the following expression: (1n + 2n + 3n + 4n) mod 5 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的倍数只用看最后两位,怕了。
//#pragma comment(linker, "/STACK:102400000,102400000")
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
#define ll long long
#define usint unsigned int
#define mz(array) memset(array, 0, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define FOR(i,x,n) for(i=(x);i<=(n);i++)
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define WN(x) printf("%d\n",x);
#define RE freopen("D.in","r",stdin)
#define WE freopen("1biao.out","w",stdout) int main() {
//RE;
ll n=;
char c,prec,preprec;
while(scanf("%c",&c)!=EOF && c>='' && c<='') {
preprec=prec;
prec=c;
n++;
}
//printf("%c,%c,%c\n",c,prec,preprec);
ll t;
if(n>) t=(preprec-'')*+(prec-'');
else t=prec-'';
if(t%==)puts("");
else puts("");
return ;
}
CF456B Fedya and Maths 找规律的更多相关文章
- Codeforces 456B Fedya and Maths 打表找规律
Description Fedya studies in a gymnasium. Fedya's maths hometask is to calculate the following expre ...
- Codeforces Round #260 (Div. 2) A B C 水 找规律(大数对小数取模) dp
A. Laptops time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- URAL 1780 G - Gray Code 找规律
G - Gray CodeTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view ...
- Codeforces Round #260 (Div. 2) A , B , C 标记,找规律 , dp
A. Laptops time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- HDU 4349 Xiao Ming's Hope 找规律
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4349 Xiao Ming's Hope Time Limit: 2000/1000 MS (Java/ ...
- hdu 3951 - Coin Game(找规律)
这道题是有规律的博弈题目,,, 所以我们只需要找出规律来就ok了 牛人用sg函数暴力找规律,菜鸟手工模拟以求规律...[牢骚] if(m>=2) { if(n<=m) {first第一口就 ...
- HDU 5703 Desert 水题 找规律
已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这 ...
- hdu4952 Number Transformation (找规律)
2014多校 第八题 1008 2014 Multi-University Training Contest 8 4952 Number Transformation Number Transform ...
- hdu 4731 2013成都赛区网络赛 找规律
题意:找字串中最长回文串的最小值的串 m=2的时候暴力打表找规律,打表可以用二进制枚举
随机推荐
- 【vijos1243】 生产产品
https://vijos.org/p/1243 (题目链接) 题意 一个产品的生产有m个步骤,一共n个机器人.机器人i完成步骤j的时间为T[i][j],每次当产品从一个机器人那里移动到另一个机器人那 ...
- 【bzoj1178】 Apio2009—CONVENTION会议中心
http://www.lydsy.com/JudgeOnline/problem.php?id=1178 (题目链接) 题意 给出n个区间,问在区间两两不相交的情况下最多能选出多少区间,并输出字典序最 ...
- 用python来调试网络程序
需要联调的程序,沟通联调起来总是各种麻烦,如果自己能写个简单一点的“测试机”,事情就很easy了:或者有时候想做“中间人”,看看网路上到底传些什么.前面写了串口的测试机,今天尝试了一下UDP的. im ...
- PowerDesigner 学习笔记
软件:PowerDesginer16.5 首先说一下对应的模型 New Model ---> Model Type 作为一个英语渣,实在是压力颇大,然而汉化经常会导致无故的BUG,所以简单翻 ...
- Visual Studio 创建WebServer
1.文件-->新建-->项目 2.Web-->Visual Studio 2012-->ASP.NET 空Web应用程序 3.右键项目-->添加-->新建项 4.选 ...
- 第三次作业——K米评测
第一部分 调研,评测 1.第一次上手体验 其实让我下载一个APP并且长期使用它是一件特别难的事情,不仅是因为占空间,需要注册个人信息,绑定账号,更是因为每款软件的功能虽然都很齐全,但是你并在没有真正用 ...
- 超强语感训练文章(Provided by Rocky teacher Prince)
Content: Class1 My name is Prince Class2 Welcome to our hotel Class3 We’re not afraid of problems Cl ...
- js 递归下的循环
的递归下的循环不能使用forEach 可以使用for代替 错误写法 // 获取完整名字 var getFullName = function(code, resultName) { if (code ...
- JS获取select选中的值,所有option值
<select name="myselect" id="myselect"> <option value="2042"&g ...
- MongoDb学习1
目标框架必须是 4.5以上,最新MongoDb.Driver 是 2.2.4(与MongoDb.Driver 的1.x版本差别较大) 官方文档 http://mongodb.github.io/mon ...
