cf 456B - Fedya and Maths

来源:互联网 发布:c语言getchar函数用法 编辑:程序博客网 时间:2024/05/21 22:48

第一眼看就觉得是个规律题。。然后暴力跑下 发现 4的倍数输出4 其他全为0

#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;int const MAXN = 1000000;char str[MAXN];int main(){    scanf("%s",str);    int s = 0;    int l = strlen(str);    for(int i = 0;i < l;i++){        s = (s * 10 + str[i] -'0') % 4;    }    //cout<<s<<endl;    if(s)printf("0\n");    else printf("4\n");    return 0;}


0 0
原创粉丝点击