码迷,mamicode.com
首页 > 其他好文 > 详细

UVA 10127 - Ones(数论)

时间:2014-06-15 15:10:41      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:style   class   code   http   tar   color   

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(数论),布布扣,bubuko.com

UVA 10127 - Ones(数论)

标签:style   class   code   http   tar   color   

原文地址:http://blog.csdn.net/accelerator_/article/details/30739777

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!