拼多多C题

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <cmath>
#pragma warning(disable:4996)


#define mn 1000010
using namespace std;
int p[mn], q[mn];
int main()
{
    int i, m, n, r, t;

    while (~scanf("%d%d", &m, &n)) {
        m = m % n;
        for (i = 0; i < mn; i++)
        {
            p[i] = -1;
            q[i] = 0;
        }
        t = 0;
        r = m;
        while (r != 0 && (p[r] == -1))
        {
            p[r] = t;
            r = 10 * r;
            t++;
            q[t] = r / n;
            r = r%n;
        }
        //printf("%d\n", r);
        if (m % n == 0)
            printf("0 0\n");
        else if (r != 0)
            printf("%d %d\n", p[r], t - p[r]);
        else {
            printf("%d %d\n", t, 0);
        }
    }
    return 0;
}

#拼多多#
全部评论
不用容器。。快一些
点赞 回复 分享
发布于 2018-08-30 21:19
ac啦?
点赞 回复 分享
发布于 2018-08-31 00:32

相关推荐

评论
点赞
收藏
分享
牛客网
牛客企业服务