zoukankan      html  css  js  c++  java
  • LightOJ

    链接:

    https://vjudge.net/problem/LightOJ-1078

    题意:

    If an integer is not divisible by 2 or 5, some multiple of that number in decimal notation is a sequence of only a digit. Now you are given the number and the only allowable digit, you should report the number of digits of such multiple.

    For example you have to find a multiple of 3 which contains only 1's. Then the result is 3 because is 111 (3-digit) divisible by 3. Similarly if you are finding some multiple of 7 which contains only 3's then, the result is 6, because 333333 is divisible by 7.

    思路:

    ((a*x+y)%b = (a%b*x%b+y%b)%b)

    代码:

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<string>
    #include<algorithm>
    #include<math.h>
    #include<vector>
    
    using namespace std;
    typedef long long LL;
    const int INF = 1e9;
    
    const int MAXN = 1e6+10;
    const int MOD = 1e9+7;
    
    int main()
    {
        int t, cnt = 0;
        LL n, x;
        scanf("%d", &t);
        while(t--)
        {
            scanf("%lld%lld", &n, &x);
            printf("Case %d: ", ++cnt);
            if (x%n == 0)
                puts("1");
            else
            {
                int cnt = 1;
                int tmp = x;
                while(x!=0)
                {
                    x = (x*10+tmp)%n;
                    cnt++;
                }
                printf("%d
    ", cnt);
            }
        }
    
        return 0;
    }
    
  • 相关阅读:
    UVA10361
    △UVA10494
    △UVA465
    △UVA10106
    △UVA424
    阶乘的精确值
    小学生算术
    UVA156
    △UVA120
    linux应用之ntpdate命令联网同步时间
  • 原文地址:https://www.cnblogs.com/YDDDD/p/11817273.html
Copyright © 2011-2022 走看看