能被3和11整除吗(数论)
来源:互联网 发布:网络的概念 编辑:程序博客网 时间:2024/04/29 06:30
A - 能被3和11整除吗
Time Limit:1000MS Memory Limit:65535KB 64bit IO Format:%lld & %lluDescription
读入一个整数,判断该数能否被
Input
有多组测试数据。输入的第一行是整数
Output
对应每组输入,输出一行判断的结果,第一个单词(yes
或no
)表示该数能否被yes
或no
)表示该数能否被
Sample Input
2
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
- 能被3和11整除吗(数论)
- poj 1152 数论(最小的进制n使得输入能被n-1整除)
- 能被9和11整除的数的特征
- 11.10 作业 Problem H: 能被3整除吗?
- 1694: 是否能被3整除? (好题)
- [证明]一个数能被3整除,当且仅当它的各位数的和能被3整除。
- 证明一个数能被3整除,当且仅当它的各位数的和能被3整除!
- 316分为两个数,一个能被13整除,一个能被11整除
- 1到100之间所有能被3和7整除的整数和
- 输出所有三位数中,能被11整除,并且各位数字和为10的数
- 为什么将能被4整除但不能被100整除和能被400整除的年份设为闰年
- C语言 - 求1~100之间,所有能被3整除的数的和值
- 判断一个数是否能同时被3和5整除 手痒之作
- 不使用%和/,判断一个整数是否能被3整除
- 求100到300之间能被3整除的数的和
- 求100-300之间能被3整除的数的和
- 能被17和37整除的数
- 能被17和37整除的数
- ProgressBar的使用以及实现进度条的增减
- 关于Bean的二三事
- freemarker简单入门Demo
- FLV科普2 FLV相关工具FlvParse
- 电子电路开发基础
- 能被3和11整除吗(数论)
- C/C++学习(五)冒泡排序
- Android资源的定义和引用
- 珍藏的链接
- 自定义ImageCache(三级缓存机制)
- 每天一点matlab——二值图像及其特征提取
- android studio 识别不出 genymotion device
- Git fatal:multiple stage entries for merged file
- Mysql 更新、删除字段、自增长字段