Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int a,b;
  6. int v[3000001], r1,r2,r3,n1,n2,n3,a1,a2,a3, j, elem;
  7. bool Freq[52000000];
  8.  
  9.  
  10.  
  11. int main()
  12. {
  13.  
  14.  
  15.  
  16. cin >> a1 >> r1 >> n1;
  17.  
  18. v[++j] = a1;
  19.  
  20. for(int i = 2; i <= n1; i++)
  21. v[++j] = v[j - 1] + r1;
  22.  
  23. cin >> a2 >> r2 >> n2;
  24.  
  25. v[++j] = a2;
  26.  
  27. for(int i = 2; i <= n2; i++)
  28. v[++j] = v[j - 1] + r2;
  29.  
  30. cin >> a3 >> r3 >> n3;
  31.  
  32. v[++j] = a3;
  33.  
  34. for(int i = 2; i <= n3; i++)
  35. v[++j] = v[j - 1] + r3;
  36.  
  37. for(int i = 1; i <= n1 + n2 + n3; i++)
  38. {
  39. if(Freq[v[i]] == 0)
  40. elem += 1;
  41.  
  42. Freq[v[i]] = 1;
  43. }
  44.  
  45. cout << elem;
  46.  
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement