题目链接

题意:给你一个数n,问最少有多少个1构成的“1”串(1,11,...)能整除n;

比如:111能被3整除; 111111能被7整除;...

作为水货觉得只要自己能1A的都是水题=。 =

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstdlib>
  4. #include<cmath>
  5. using namespace std;
  6. const int maxn = ;
  7. int main()
  8. {
  9. int n, p[maxn];
  10. while(~scanf("%d", &n))
  11. {
  12. if(!n) {printf("0\n"); continue;}
  13. int len = log10(n)+;
  14. int val = , x;
  15. for(x = ; x < len; x++)
  16. {
  17. val = val* + ;
  18. }
  19. int res = ;
  20. if(val/n == )
  21. {
  22. val = val*+;
  23. x++;
  24. }
  25. res = val%n;
  26. while(res)
  27. {
  28. res = res*+;
  29. res = res%n;
  30. x++;
  31. }
  32. printf("%d\n", x);
  33. }
  34. return ;
  35. }

【数论,水题】UVa 10127 - Ones的更多相关文章

  1. [ACM_水题] UVA 12502 Three Families [2人干3人的活后分钱,水]

      Three Families  Three families share a garden. They usually clean the garden together at the end o ...

  2. HDU 3215 The first place of 2^n (数论-水题)

    The first place of 2^n Problem Description LMY and YY are mathematics and number theory lovers. They ...

  3. POJ 1061 青蛙的约会 数论水题

    http://poj.org/problem?id=1061 傻逼题不多说 (x+km) - (y+kn) = dL 求k 令b = n-m ; a = x - y ; 化成模线性方程一般式 : Lx ...

  4. [ACM_水题] UVA 11729 Commando War [不可同时交代任务 可同时执行 最短完成全部时间 贪心]

    There is a war and it doesn't look very promising for your country. Now it's time to act. You have a ...

  5. [ACM_水题] UVA 11292 Dragon of Loowater [勇士斗恶龙 双数组排序 贪心]

    Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shor ...

  6. Coprime Arrays CodeForces - 915G (数论水题)

    反演一下可以得到$b_i=\sum\limits_{d=1}^i{\mu(i)(\lfloor \frac{i}{d} \rfloor})^n$ 整除分块的话会T, 可以维护一个差分, 优化到$O(n ...

  7. HDU 1576 A/B 数论水题

    http://acm.hdu.edu.cn/showproblem.php?pid=1576 写了个ex_gcd的模板...太蠢导致推了很久的公式 这里推导一下: 因为 1 = BX + 9973Y ...

  8. UVa 489 HangmanJudge --- 水题

    UVa 489 题目大意:计算机给定一个单词让你猜,你猜一个字母,若单词中存在你猜测的字母,则会显示出来,否则算出错, 你最多只能出错7次(第6次错还能继续猜,第7次错就算你失败),另注意猜一个已经猜 ...

  9. UVa 1339 Ancient Cipher --- 水题

    UVa 1339 题目大意:给定两个长度相同且不超过100个字符的字符串,判断能否把其中一个字符串重排后,然后对26个字母一一做一个映射,使得两个字符串相同 解题思路:字母可以重排,那么次序便不重要, ...

随机推荐

  1. JavaScript——对this指针的新理解

    一直以来对this的理解只在可以用,会用,却没有去深究其本质.这次,借着<JavaScript The Good Parts>,作了一次深刻的理解.(所有调试都可以在控制台中看到,浏览器F ...

  2. poj 3026 Borg Maze (BFS + Prim)

    http://poj.org/problem?id=3026 Borg Maze Time Limit:1000MS     Memory Limit:65536KB     64bit IO For ...

  3. poj 3693 Maximum repetition substring (后缀数组)

    其实是论文题.. 题意:求一个字符串中,能由单位串repeat得到的子串中,单位串重复次数最多的子串.若有多个重复次数相同的,输出字典序最小的那个. 解题思路:其实跟论文差不多,我看了很久没看懂,后来 ...

  4. POJ 3673 Cow Multiplication (水题)

    题意:给你两个数,求所有的数位的积的和. 析:太水了,没的说,可以先输入边算,也可以最后再算,一样.. 代码如下: #include <cstdio> #include <strin ...

  5. C#多线程开发

    1.进程与线程的区别 通俗的讲,进行就是任务管理器中进行列表中看到的正在运行的程序,它是一个动态的概念,活动的实体. 线程是程序执行流的最小单元,是线程中一个实体,是系统独立调度和分派CPU基本单位. ...

  6. 超级终端和SecureCRT进行Console口的连接

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html 内部邀请码:C8E245J (不写邀请码,没有现金送) 国 ...

  7. 【转】Rails 3.1错误-Could not find a JavaScript runtime及execjs和therubyracer介绍

    转自:http://rubyer.me/blog/740/ Rails 3.1错误 /gems/execjs-1.1.2/lib/ execjs/runtimes.rb:43:in `autodete ...

  8. HDU 3410 &amp;&amp; POJ 3776 Passing the Message 单调队列

    题意: 给定n长的数组(下标从1-n)(n个人的身高,身高各不同样 问:对于第i个人,他能看到的左边最矮的人下标.(假设这个最矮的人被挡住了,则这个值为0) 还有右边最高的人下标,同理若被挡住了则这个 ...

  9. 算法优化:rgb向yuv的转化最优算法,快得让你吃惊!

    朋友曾经给我推荐了一个有关代码优化的pdf文档<让你的软件飞起来>,看完之后,感受颇深.为了推广其,同时也为了自己加深印象,故将其总结为word文档.下面就是其的详细内容总结,希望能于己于 ...

  10. iOS开发——总结篇&常用开发总结

    一.通知1.监听通知 - (void)addObserver:(id)observer selector:(SEL)aSelector name:(NSString *)aName object:(i ...