fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int n;
  6. int t = 1;
  7. int c;
  8.  
  9. while(~scanf("%d", &n))
  10. {
  11. t=1;
  12. for(int i = 2; t%n!=0; i++)
  13. {
  14. t = t*10 + 1;
  15. t %= n;
  16. c = i;
  17. if(t<0){printf("?"); break;}
  18. }
  19.  
  20. printf("%d\n", c);
  21. }
  22. }
Success #stdin #stdout 0.01s 5308KB
stdin
3
7
9901
stdout
3
6
12