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

  1. 1v3
  2. 2P6
  3. IsThisDivisible
  4. end

Sample Output

  1. yes
  2. no
  3. no

Source

SLPC 2007

62进制的数是否能被61整除。

输入的数达10000位,但是可以一边运算一边mod。

  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int convertToInt(char a){
  5. if(''<=a && a<='')return a-'';
  6. if('A'<=a && a<='Z')return a-'A'+;
  7. if('a'<=a && a<='z')return a-'a'+;
  8. }
  9.  
  10. int main()
  11. {
  12. char ch[];
  13. while( scanf("%s",ch), strcmp("end",ch)!= ){
  14. int mo=;
  15. int temp=;
  16. for(int i=; ch[i]!='\0'; i++,temp*=){
  17. mo+=convertToInt(ch[i])*temp;
  18. mo%=;
  19. temp%=;
  20. }
  21. if(mo==){
  22. puts("yes");
  23. }else{
  24. puts("no");
  25. }
  26. }
  27. return ;
  28. }

TOJ 3486 Divisibility的更多相关文章

  1. TOJ 2776 CD Making

    TOJ 2776题目链接http://acm.tju.edu.cn/toj/showp2776.html 这题其实就是考虑的周全性...  贡献了好几次WA, 后来想了半天才知道哪里有遗漏.最大的问题 ...

  2. cf306 C. Divisibility by Eight(数学推导)

    C. Divisibility by Eight time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  3. 周赛-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 ...

  4. 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/ ...

  5. Divisibility by Eight (数学)

    Divisibility by Eight time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  6. codeforces 630J Divisibility

    J. Divisibility time limit per test 0.5 seconds memory limit per test 64 megabytes input standard in ...

  7. Codeforces Testing Round #12 A. Divisibility 水题

    A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...

  8. Divisibility

    Description Consider an arbitrary sequence of integers. One can place + or - operators between integ ...

  9. HDU 3335 Divisibility (DLX)

    Divisibility Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit ...

随机推荐

  1. centos7下git的安装和配置

    git的安装: yum 源仓库里的 Git 版本更新不及时,最新版本的 Git 是 1.8.3.1,但是官方最新版本已经到了 2.9.2.想要安装最新版本的的 Git,只能下载源码进行安装. 1. 查 ...

  2. Oracle下载及安装

    Oracle   下载及安装 一.官方下地址:   http://www.oracle.com/technetwork/database/enterprise-edition/downloads/in ...

  3. 关于命名空间 namespace的总结

    namespace 有作用的类型  类.函数.常量关键字namespace必须在所有代码之前 除用于编码的declare语句 namespace Myproject; const A = 1; cla ...

  4. NSData 数据

    前言 NSData 和它的可变长子类 NSMutableData 是字节缓冲区的对象化封装.我们可以获得简单缓冲区,并进行一些转换操作. 通常我们并不会直接创建字节数据,而是从其他类型的内容转换成字节 ...

  5. django使用auth模块进行身份认证

    https://docs.djangoproject.com/zh-hans/2.0/topics/auth/default/#authentication-in-web-requests djang ...

  6. struts2官方 中文教程 系列一:创建一个struts2 web Application

    先贴了本帖地址,以免被爬  http://www.cnblogs.com/linghaoxinpian/p/6898779.html 本教程将会通过安装struts2框架来创建一个简单的应用程序.虽然 ...

  7. OOP2(虚函数/抽象基类/访问控制与继承)

    通常情况下,如果我们不适用某个函数,则无需为该函数提供定义.但我们必须为每个虚函数都提供定义而不管它是否被用到了,这因为连编译器也无法确定到底会适用哪个虚函数 对虚函数的调用可能在运行时才被解析: 当 ...

  8. cookie,session 的概念以及在django中的用法,以及cbv装饰器用法

    cookie的由来: 大家都知道HTTP协议是无状态的. 无状态的意思是每次请求都是独立的,它的执行情况和结果与前面的请求和之后的请求都无直接关系,它不会受前面的请求响应情况直接影响,也不会直接影响后 ...

  9. linux系统安全及应用——弱口令检测

    Joth the Ripper,简称JR,一款密码分析工具,支持字典式的暴力破解,通过对shadow文件的口令分析,可以检测密码强度,官方网站http://www.openwall.com/john/ ...

  10. org.apache.storm.utils.NimbusLeaderNotFoundException: could not find leader nimbus from seed hosts["datanode9"]. Did you specify a valid of nimbus hosts for config nimbus.seeds?

    出现这个异常的原因主要是zookeeper没有正常工作引起的.可以在storm-conf-storm.yaml中设置 storm.zookeeper.servers: -"zookeeper ...