能被3和11整除吗(数论)

来源:互联网 发布:网络的概念 编辑:程序博客网 时间:2024/04/29 06:30
A - 能被3和11整除吗
Time Limit:1000MS     Memory Limit:65535KB     64bit IO Format:%lld & %llu
Submit Status

Description

读入一个整数,判断该数能否被整数。注意该数可能很大,它的范围为

Input

有多组测试数据。输入的第一行是整数),表示测试数据的组数。每一组测试数据只有一行,即为要判断的整数。该行没有其它多余的符号。

Output

对应每组输入,输出一行判断的结果,第一个单词(yesno)表示该数能否被整除,第二个单词(yesno)表示该数能否被整除,两个字符串之间用一个空格隔开。该行不能有其它多余的符号。

Sample Input


2896 
27824277658778257401

Sample Output

no no 
yes no



参考资料


AC代码:


#include<iostream>#include<algorithm>#include<cstring>#include<string>#include<cstdio>using namespace std;int main(){#ifdef zscfreopen("input.txt","r",stdin);#endifint n;string s;cin >> n;while(n--){   cin >> s;   int m,c,k;   m = k = 0;   c = s.size();    for(int i=c-1;i>=0;--i){   int d = s[i]-'0';    m+=d;   if(i&1){   k-=d;   } else {   k+=d;   }   }   if(m%3==0){   cout << "yes ";   } else {   cout << "no ";   }   if(k%11==0){   cout << "yes\n";   } else {   cout << "no\n";   }}return 0;}


0 0
原创粉丝点击