`
阿尔萨斯
  • 浏览: 4150366 次
社区版块
存档分类
最新评论

Codeforces 456B Fedya and Maths(数学)

 
阅读更多

题目链接: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;
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics