Define the function S(x) for x 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
思路:使k的各位和始终为233,k*x的各位和(乘出来找规律)就为233个x的各个位上的数的和的和。
借鉴的大神的代码:
#include <cstdio> using namespace std; int lenght(int n) { int len=0; while(n) { len++; n/=10; } return len; } int main() { int T,x,i; scanf("%d",&T); while(T--) { scanf("%d",&x); int len=lenght(x); printf("1"); switch(len) { case 1: for(i=1;i<233;i++) printf("1"); break; case 2: for(i=1;i<233;i++) printf("01"); break; case 3: for(i=1;i<233;i++) printf("001"); break; case 4: for(i=1;i<233;i++) printf("0001"); break; case 5: for(i=1;i<233;i++) printf("00001"); break; case 6: for(i=1;i<233;i++) printf("000001"); break; case 7: for(i=1;i<233;i++) printf("0000001"); break; } printf("\n"); } return 0; }
方法二:#include<cstdio> #include<cstring> using namespace std; int main() { int T; scanf("%d",&T); while(T--) { int n; scanf("%d",&n); int i; for(i=1;i<=233;i++) printf("%d",(int)233/n); printf("\n"); } return 0; }