【数论,水题】UVa 10127 - Ones
题意:给你一个数n,问最少有多少个1构成的“1”串(1,11,...)能整除n;
比如:111能被3整除; 111111能被7整除;...
作为水货觉得只要自己能1A的都是水题=。 =
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;
const int maxn = ;
int main()
{
int n, p[maxn];
while(~scanf("%d", &n))
{
if(!n) {printf("0\n"); continue;}
int len = log10(n)+;
int val = , x;
for(x = ; x < len; x++)
{
val = val* + ;
}
int res = ;
if(val/n == )
{
val = val*+;
x++;
}
res = val%n;
while(res)
{
res = res*+;
res = res%n;
x++;
}
printf("%d\n", x);
}
return ;
}
【数论,水题】UVa 10127 - Ones的更多相关文章
- [ACM_水题] UVA 12502 Three Families [2人干3人的活后分钱,水]
Three Families Three families share a garden. They usually clean the garden together at the end o ...
- 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 ...
- POJ 1061 青蛙的约会 数论水题
http://poj.org/problem?id=1061 傻逼题不多说 (x+km) - (y+kn) = dL 求k 令b = n-m ; a = x - y ; 化成模线性方程一般式 : Lx ...
- [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 ...
- [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 ...
- Coprime Arrays CodeForces - 915G (数论水题)
反演一下可以得到$b_i=\sum\limits_{d=1}^i{\mu(i)(\lfloor \frac{i}{d} \rfloor})^n$ 整除分块的话会T, 可以维护一个差分, 优化到$O(n ...
- HDU 1576 A/B 数论水题
http://acm.hdu.edu.cn/showproblem.php?pid=1576 写了个ex_gcd的模板...太蠢导致推了很久的公式 这里推导一下: 因为 1 = BX + 9973Y ...
- UVa 489 HangmanJudge --- 水题
UVa 489 题目大意:计算机给定一个单词让你猜,你猜一个字母,若单词中存在你猜测的字母,则会显示出来,否则算出错, 你最多只能出错7次(第6次错还能继续猜,第7次错就算你失败),另注意猜一个已经猜 ...
- UVa 1339 Ancient Cipher --- 水题
UVa 1339 题目大意:给定两个长度相同且不超过100个字符的字符串,判断能否把其中一个字符串重排后,然后对26个字母一一做一个映射,使得两个字符串相同 解题思路:字母可以重排,那么次序便不重要, ...
随机推荐
- crontab 定时任务格式
如下内容节选自<Linux Crontab 定时任务 命令详解> 用crontab -e 添加要执行的命令 添加的命令必须以如下格式: * * * * * /command path 前五 ...
- Spring Named Parameters examples in SimpleJdbcTemplate
In JdbcTemplate, SQL parameters are represented by a special placeholder "?" symbol and bi ...
- 【PYTHON】二维码生成
二维码是什么? 二维码从一维码扩展而来,增加另一维具有可读性的条码,用黑白矩形图形表示二进制数据,被设备扫描后获取其中包含的信息,二维码的长度.宽度均记载着数据,二维码具有定位点和容错机制,即便没有辨 ...
- 哥也能写KMP了——实现strstr()
经过上次去面试,面试官要求实现strstr(),当场就蒙了.这个题目是模式匹配问题,<算法导论>里列出了几种字符串匹配算法: 朴素算法 | Rabin-Karp | 有限自动机算法 | ...
- contiki-main.c 一 打印观察 <contiki学习之五>
说明: 本文依赖于 contiki/platform/native/contiki-main.c 文件. 在项目工程目录下的hello-world.c 文件里面,有许多的宏,但没有最关键的main() ...
- Get-ChildItem参数之 -Exclude,Filter,Recurse应用
$p = "D:\PSScript" gci $p -Exclude "UpdateLog" #排除子目录"UpdateLog",但是后面不 ...
- Sysprep命令详解
本主题描述了 Windows(R) 8 版本的系统准备 (Sysprep) 工具的命令行语法. 如果你打算创建安装映像以部署到不同的计算机上,则必须运行带有 /generalize 选项的 Syspr ...
- LCD_ILI9320横竖屏方向的问题。
发现仅仅设置R03H是不能设置方向的,还需要设置R32H,R33H的坐标位置. 比如我现在是 R03H=0x1000H,R20H=239-x,R21H=319-y:竖直正向 R03H=0x1030H, ...
- 也谈读书和书籍选择问题(C#)
前言 读到一篇.net程序员应该看什么书?深有感触.以前曾经用C#也开发过几年的东西.在那里对相关语言和开发都有了一定的了解.这里,结合自己当初的一些体会和见识把一些比较好的书籍也和大家分享一下.这一 ...
- decide your linux OS is GUI or not
Try: ps -ef|grep X The ps command will display information about a selection of the active process ...