fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.  
  5. // your code goes here
  6. //freopen("input.txt", "r", stdin);
  7. //freopen("output.txt", "w", stdout);
  8.  
  9. int n,k,i,l,c, p[1000000], ind, chk;
  10. scanf("%d\n",&n);
  11. int v[n];
  12. for (i=1;i<=n;i++){
  13. scanf("%d",&v[i]);
  14. }
  15. i=1;
  16. p[1]=1;
  17. chk=0;
  18. do {
  19. i++;
  20. k=p[i-1];
  21. p[i]=(p[i-1]+v[k])%n+1;
  22. //printf ("%d ",p[i]);
  23. for (ind=1;ind<i;ind++){
  24. if (p[ind]==p[i]){
  25. chk=1;
  26. i=i-1;
  27. }
  28. }
  29. } while (chk==0);
  30. c=0;
  31. for (k=1;k<=i;k++){
  32. l=p[k];
  33. v[l]=-1;
  34. c++;
  35. }
  36. printf("\n%d\n", n-c);
  37. for (k=1;k<=n;k++){
  38. if (v[k]>=0)
  39. printf("%d ",k);
  40. }
  41.  
  42. return 0;
  43. }
  44.  
Success #stdin #stdout 0s 13216KB
stdin
100
32 32 72 22 44 3 75 92 7 49 95 94 85 59 63 56 57 20 68 56 45 4 42 51 38 33 68 67 40 88 67 95 86 45 83 31 66 80 52 76 50 4 86 48 79 49 39 73 50 15 15 10 17 22 65 57 90 62 58 96 43 15 26 8 90 93 40 64 75 32 70 14 97 78 56 6 13 12 89 81 61 66 97 18 84 3 21 22 54 22 74 39 90 91 83 16 55 52 15 5
stdout
69
2 3 4 5 6 7 8 10 11 12 14 16 18 19 20 21 23 24 26 29 30 31 33 35 36 37 38 39 40 41 43 44 46 49 50 51 52 53 54 55 56 58 59 61 63 65 67 68 70 72 74 76 77 81 82 83 84 85 86 88 89 90 92 93 94 95 97 98 100