Description
由n個1組成的整數能被K(K<10000)整除,n至少為多少?
Input
多組測試數據,第一行輸入整數T,表示組數 然后是T行,每行輸入1個整數代表K
Output
對於每組測試數據輸出1行,值為n
Sample Input
1 11
Sample Output
2
#include <stdio.h> #include <stdlib.h> int main(void) { int t; while(scanf("%d",&t)!=EOF) { while(t--) { int k; scanf("%d",&k); if(k==1) { printf("1\n"); continue; }int c=1; int temp=1; while(temp!=0) { temp=temp*10+1; temp=temp%k; c++; } printf("%d\n",c); } } return 0; }