您的位置:首页

UVA 10127 - Ones(数论)

2017-05-22 12:52 218 查看


UVA 10127 - Ones

题目链接

题意:求出多少个1组成的数字能整除n

思路:一位位去取模。记录答案就可以

代码:

#include <stdio.h>
#include <string.h>

int n;

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