TOJ 3486 Divisibility
Description
On the planet Zoop, numbers are represented in base 62, using the digits
0, 1, . . . , 9, A, B, . . . , Z, a, b, . . . , z
where
A (base 62) = 10 (base 10)
B (base 62) = 11 (base 10)
...
z (base 62) = 61 (base 10).
Given the digit representation of a number x in base 62, your goal is to determine if x is divisible by 61.
Input
The
input test file will contain multiple cases. Each test case will be
given by a single string containing only the digits ‘0’ through ‘9’, the
uppercase letters ‘A’ through ‘Z’, and the lowercase letters ’a’
through ’z’. All strings will have a length of between 1 and 10000
characters, inclusive. The end-of-input is denoted by a single line
containing the word “end”, which should not be processed. For example:
1v3
2P6
IsThisDivisible
end
Output
For each test case, print “yes” if the number is divisible by 61, and “no” otherwise. For example:
yes
no
no
In the first example, 1v3 = 1 × 622 + 57 × 62 + 3 = 7381, which is divisible by 61.
In the second example, 2P6 = 2 × 622 + 25 × 62 + 6 = 9244, which is not divisible by 61.
Sample Input
1v3
2P6
IsThisDivisible
end
Sample Output
yes
no
no
Source
62进制的数是否能被61整除。
输入的数达10000位,但是可以一边运算一边mod。
#include <stdio.h>
#include <string.h> int convertToInt(char a){
if(''<=a && a<='')return a-'';
if('A'<=a && a<='Z')return a-'A'+;
if('a'<=a && a<='z')return a-'a'+;
} int main()
{
char ch[];
while( scanf("%s",ch), strcmp("end",ch)!= ){
int mo=;
int temp=;
for(int i=; ch[i]!='\0'; i++,temp*=){
mo+=convertToInt(ch[i])*temp;
mo%=;
temp%=;
}
if(mo==){
puts("yes");
}else{
puts("no");
}
}
return ;
}
TOJ 3486 Divisibility的更多相关文章
- TOJ 2776 CD Making
TOJ 2776题目链接http://acm.tju.edu.cn/toj/showp2776.html 这题其实就是考虑的周全性... 贡献了好几次WA, 后来想了半天才知道哪里有遗漏.最大的问题 ...
- cf306 C. Divisibility by Eight(数学推导)
C. Divisibility by Eight time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- 周赛-Clique in the Divisibility Graph 分类: 比赛 2015-08-02 09:02 23人阅读 评论(3) 收藏
Clique in the Divisibility Graph time limit per test1 second memory limit per test256 megabytes inpu ...
- Codeforces Round #306 (Div. 2) C. Divisibility by Eight 暴力
C. Divisibility by Eight Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...
- Divisibility by Eight (数学)
Divisibility by Eight time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- codeforces 630J Divisibility
J. Divisibility time limit per test 0.5 seconds memory limit per test 64 megabytes input standard in ...
- Codeforces Testing Round #12 A. Divisibility 水题
A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...
- Divisibility
Description Consider an arbitrary sequence of integers. One can place + or - operators between integ ...
- HDU 3335 Divisibility (DLX)
Divisibility Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
随机推荐
- 适配器(Adapter)模式
一. 适配器(Adapter)模式 适配器模式把一个类的接口变换成客户端所期待的另一种接口,从而使原本接口不匹配而无法在一起工作的两个类能够在一起工作 二. 类的Adapter模式的结构: 目标(Ta ...
- 完美解决bootstrap模态框允许拖动后拖出边界的问题
使用bootstrap3版本 在网上看了很多方法,我觉得jquery-ui的实现方法是最简单有效的,具体实现方法 1.下载并引入jquery-ui插件 2.全局添加模态框允许拖动事件 $(docume ...
- 记.gitignore的一次惊心动魄
git rm -r --cached . #清除缓存 git add . #重新trace file git commit -m "update .gitignore" #提交和 ...
- WINDOWS权限大牛们,请进
大家好, 我遇到一个问题,我的一台windows7去访问另一个电脑的共享,输入账号密码后,老是说密码不正确.而其他电脑去访问共享,密码账号密码后都OK 我想知道原因是什么?
- C#backgroundWorker
private void button1_Click(object sender, EventArgs e) { backgroundWorker1.RunWorkerAsync(); } priva ...
- Vue 父组件向子组件传值,传方法,传父组件整体
父子组件传值 1.父组件调用子组件时绑定属性,例如-> :title="title" 2.子组件中在props中声明title:props:['title','msg'] 3 ...
- 严选 Android 路由框架优化(上篇)
0 背景 早前严选 Android 工程,使用原生 Intent 方式做页面跳转,为规范参数传递,做了编码规范,使用静态方法的方式唤起 Activity public static void star ...
- 存入azure table时忽略某个属性
public class CustomTableEntity : TableEntity { public override IDictionary<string, EntityProperty ...
- 190308python-MySQL
一.Python连接MySQL import pymysql conn = pymysql.connect(host='192.168.100.4', port=3306, user='dongfei ...
- 洛谷 P2330 [SCOI2005]繁忙的都市(最小生成树)
嗯... 题目链接:https://www.luogu.org/problemnew/show/P2330 这道题的问法也实在是太模板了吧: 1.改造的道路越少越好 2.能够把所有的交叉路口直接或间接 ...