山东省第八届ACM省赛 I 题(Parity check)
2017-05-10 21:38
309 查看
Problem Description
Fascinated with the computer games, Gabriel even forgets to study. Now she needs to finish her homework, and there is an easy problem:f(n)=
She is required to calculate f(n) mod 2 for each given n. Can you help her?
Input
Multiple test cases. Each test case is an integer n(0≤n≤) in a single line.
Output
For each test case, output the answer of f(n)mod2.Example Input
2
Example Output
1
题意:这个题很简单,就是找规律,当n%3==0时输出0,n%3==1||2输出1;
#include<iostream>#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
char c[1010]; //这个地方要注意,开大点;
int main()
{
while(scanf("%s",c)!=EOF)
{
int len=strlen(c);
int sum=0;
for(int i=0; i<len; i++)
{
sum=(sum*10+(c[i]-'0'))%3;
}
if(sum==0) printf("0\n");
else if(sum==1||sum==2) printf("1\n");
}
return 0;
}
相关文章推荐
- 山东省第八届ACM省赛 I 题 Parity check 详解
- 山东省第八届acm省赛C题 巨坑
- SDUT 3895 (山东省第八届ACM省赛C题) fireworks 杨辉三角+乘法逆元
- 山东省第八届acm省赛 HEX
- 山东省第八届ACM省赛 F 题(quadratic equation)
- 山东省第八届acm省赛 Return of the Nim
- 山东省第八届acm省赛D题HEX(组合数学)
- 2017山东省第八届ACM省赛 fireworks(杨辉三角 + 逆元)
- 山东省第八届 ACM 省赛 Parity check (规律、水)
- 山东省第八届ACM省赛C firework
- 山东省第八届ACM省赛A题
- 山东省第八届acm省赛E题 三分+二分
- 山东省第八届ACM省赛 D.HEX
- 山东省第八届ACM省赛 F题 quadratic equation (详解)
- [置顶] 2017年山东省第八届acm省赛总结
- 山东省第八届ACM省赛 Problem.H triangle
- 山东省第八届acm省赛B题 打表找规律
- 山东省第八届ACM省赛C题
- 山东省第八届acm省赛A题 博弈
- 山东省第八届acm省赛C题 fireworks