拼多多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;
}
#拼多多#
#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;
}