您的位置:首页 > 其它

山东省第八届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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  省赛题目