fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int maxN = 1e6+5;
  4.  
  5. int n, a[maxN], b[maxN];
  6.  
  7. void solve()
  8. {
  9. int x = 1, y = 1, ans = 0;
  10. for(int i=1; i<=n; i+=1)
  11. {
  12. cout<<x<<'\n';
  13. if(__gcd(x, a[i]) == x)
  14. {
  15. ans++;
  16. }
  17. x = __gcd(x,a[i]);
  18. }
  19. cout<<ans<<'\n';
  20. }
  21.  
  22. int main() {
  23. int test = 1;
  24. cin>>test;
  25. while(test--)
  26. {
  27. cin>>n;
  28. for(int i=1; i<=n; i+=1) cin>>a[i];
  29. for(int i=1; i<=n; i+=1) cin>>b[i];
  30. solve();
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0.01s 5632KB
stdin
1
7
1 2 3 4 5 6 7
1 2 3 4 5 6 7
3
67 67 67
67 67 67
6
8 10 10 12 12 14
8 10 10 12 12 14
8
2 4 8 16 32 64 128 256
2 4 8 16 32 64 128 256
stdout
1
1
1
1
1
1
1
7