Advertisement
ShafiulAzim

uva 10050

Feb 29th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t,n,np,i,p,c,x,j;
  6. cin>>t;
  7. while(t--)
  8. {
  9. c=0;
  10. cin>>n>>np;
  11. int arr[n];
  12. for(i=0; i<n; i++)
  13. {
  14. arr[i]=0;
  15. }
  16. for(j=0;j<np;j++)
  17. {
  18. x=0;
  19. cin>>p;
  20. for(i=1; ; i++)
  21. {
  22. x=(p*i);
  23. if(x>n)
  24. break;
  25. else if(x%7!=0 && x%7!=6)
  26. {
  27. arr[x-1]=1;
  28. }
  29. }
  30. }
  31.  
  32. for(i=0; i<n; i++)
  33. {
  34. if(arr[i]==1)
  35. c++;
  36. }
  37. cout<<c<<endl;
  38. }
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement