# 圆周率

YT大学附小举办背诵圆率 PI 的比赛。谁背的正确的位数越多，谁为胜者。很多小学生背的位数很多，但是往往会有少数位置的数是错误的。为了快速加测出错误的圆周率，将圆周率 PI 小数点后的数字求模进行简单验证。

782910 mod 9 =  8
377777777777777738 mod 7 =6
1234567 mod 6 =3
(注意：377777777777777738=112589990684261910   1234567 =2287510 )

第一行表示为整数P(1P1000)，表示一共的测试数据组数。

``````6
1 10 7829
2 7 12345
3 6 432504023545112
4 8 37777777777777773
5 2 101011111111110000000000000000000011111111111111111111111
6 10 145784444444444457842154777777777547845993``````

``````1 8
2 3
3 1
4 6
5 0
6 6
``````

``````#include <stdio.h>
#include <assert.h>
#include <ctype.h>

int main()
{
int p, i, i1, b, result, c;
scanf("%d", &p);				/* get # of data sets */
for (i = 0; i < p; i++) {
scanf("%d %d ", &i1, &b);	/* trailing space in fmt eats spaces */
assert(i1 == i + 1);		/* between B and N */
result = 0;
while (isdigit(c = getchar())) {
result = (result + c - '0') % (b - 1);
}
printf("%d %d\n", i1, result);
}
return 0;
}``````

``````#include <stdio.h>
#include <assert.h>
#include <ctype.h>

int main()
{
int p, i, i1, b, result, c;
scanf("%d", &p);				/* get # of data sets */
for (i = 0; i < p; i++) {
scanf("%d %d ", &i1, &b);	/* trailing space in fmt eats spaces */
assert(i1 == i + 1);		/* between B and N */
result = 0;
while (isdigit(c = getchar())) {
result = (result + c - '0') % (b - 1);
}
printf("%d %d\n", i1, result);
}
return 0;
}``````