题目来源:Sum
限制:1000ms 32768K Define the function S(x) for xx is a positive integer. S(x) equals to the sum of all digit of the decimal expression of x. Please find a positive integer k that S(k∗x)%233=0.
Input Format
First line an integer T, indicates the number of test cases (T≤100). Then Each line has a single integer x(1≤x≤1000000) indicates i-th test case.
Output Format
For each test case, print an integer in a single line indicates the answer. The length of the answer should not exceed 2000. If there are more than one answer, output anyone is ok.
样例输入 1 1 样例输出
89999999999999999999999999
下面以X==1为例,那么 k=11111……11(233个1)是可以的 同理x=2~9的时候,k=xxx……x(233个x)是可以的 但是10以上的时候这样的答案就不能满足了, 如果x=13,k如果等于k=xxx……x(233个x),那么S(k*x)%233==0就不能保证了, 这个时候考虑结果,x=13,如果k*x=xxx……x(233个x), 那么k * x/ x的结果就是1010……10(233个10); 同理可以扩展到x=133(三位数),这时就是100……100(233个100); 像1333(四位数),则k可以等于1000……1000(233个1000); 输出结果取决于x的位数。
完整代码:
#include<stdio.h>
#define MAX 2000
int main(void)
{
int T, x, num;
scanf("%d", &T);
while (T-- > 0)
{
num = 0;
scanf("%d",&x);
while (x > 0)
{
num++;
x /= 10;
}
if (num == 1)
{
for (int i = 0; i < 233; i++)
printf("%d",x);
}
if (num == 2)
{
for (int i = 0; i < 233; i++)
printf("10");
}
if (num == 3)
{
for (int i = 0; i < 233; i++)
printf("100");
}
if (num == 4)
{
for (int i = 0; i < 233; i++)
printf("1000");
}
if (num == 5)
{
for (int i = 0; i < 233; i++)
printf("10000");
}
if (num == 6)
{
for (int i = 0; i < 233; i++)
printf("100000");
}
printf("\n");
}
return 0;
}