题目链接:Codeforces 456B Fedya and Maths
题目大意:给定一个数n,求题目给定公式的值。
解题思路:n为4的倍数时答案为4,否则为0,取模质数时的性质,以前做过相同的题目。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 1e5+5;
char s[maxn];
int main () {
scanf("%s", s);
int len = strlen(s);
int ans = 0;
for (int i = 0; i < len; i++)
ans = (ans * 10 + s[i] - '0') % 4;
printf("%d\n", ans == 0 ? 4 : 0);
return 0;
}