您的位置:首页 > 其它

uva 10127 - Ones(数论)

2015-02-17 13:11 567 查看
题目链接:uva 10127 - Ones

题目大意:给出n,问说者少要多少为1才干够整除n。

解题思路:等于是高精度取模,直到余数为0为止。

#include <cstdio>
#include <cstring>

int main () {
int n;
while (scanf("%d", &n) == 1) {
int ans = 1, c = 1;
while (c) {
c = (c * 10 + 1) % n;
ans++;
}
printf("%d\n", ans);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: