fork(1) download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. int main()
  4. {
  5. int T;
  6. scanf("%d",&T);
  7. for(int i=0;i<T;i++)
  8. {
  9. int N,P,h[101],D[3651];
  10. scanf("%d %d",&N,&P);
  11. for(int j=0;j<P;j++)
  12. {
  13. scanf("%d",&h[j]);
  14. if(D[h[j]]>=1)
  15. D[h[j]]++;
  16. else
  17. D[h[j]]=1;
  18. int tem=h[j];
  19. h[j]+=tem;
  20. while(h[j]<=N)
  21. {
  22. if(D[h[j]]>=1)
  23. D[h[j]]++;
  24. else
  25. D[h[j]]=1;
  26. h[j]+=tem;
  27. }
  28. }
  29. int k=1,H=0,flags=7;
  30. while(k<=N)
  31. {
  32. if(D[k]>=1)
  33. {
  34. D[k]=0;
  35. H++;
  36. }
  37. if(k==(flags-2))
  38. {
  39. k+=2;
  40. flags+=7;
  41. }
  42. k++;
  43. }
  44. printf("%d\n",H);
  45. }
  46. return 0;
  47. }
Success #stdin #stdout 0s 2900KB
stdin
10
1685
3
1473
975
726
2614
7
1371
2162
2487
906
2179
1858
16
3585
2
908
1112
882
9
29
640
493
431
577
653
523
243
4
1379
12
32
956
1198
451
89
562
837
143
719
34
951
365
2620
10
2
2530
461
1658
297
1929
1923
152
463
2202
2690
6
2545
2348
1959
209
577
967
2130
12
888
877
813
2049
954
310
1765
1920
1951
1294
1033
1032
814
1
794
370
4
120
121
87
226
stdout
4
121
66
183
86
946
16
19
1
9