首页 > 其他 > 详细

UVA 10127 - Ones(数论)

时间:2017-05-22 14:11:12      阅读:227      评论:0      收藏:0      [点我收藏+]

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;
}

UVA 10127 - Ones(数论)

原文:http://www.cnblogs.com/llguanli/p/6888953.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!