Description
求 N 是不是6的倍数,输出YES 或 no
Input
多组测试样例
第一行输入T(T<10000) 表示T组样例
接下来每行输入一个整数N (0<=N<=10^10000)
Output
是6的倍数输出 YES ,否则输出 no
3 1 6 12Sample Output 1
no YES YES
因为是大数 所以刚开始 把这道题想歪了。。。。
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; char s[25000]; int main() { int t; scanf("%d",&t); getchar(); while(t--) { gets(s); int len=strlen(s); if((s[len-1]-'0')%2!=0) { printf("no\n"); continue; } int ans=0; for(int i=0;i<len;i++) { ans+=(s[i]-'0'); } if(ans%3==0) { printf("YES\n"); }else printf("no\n"); }return 0; }
判断一个大数是不是6的倍数(水题)
最新推荐文章于 2021-05-19 07:07:02 发布