fork download
  1. /*input
  2. 5 5
  3. 2 2 7 14 14
  4. 1 1 3
  5. 1 2 6
  6. 2 2
  7. 2 4
  8. 2 5
  9. */
  10. #include<bits/stdc++.h>
  11. using namespace std;
  12. const int N=1e6 + 100;
  13. const int mod=1e9 + 7;
  14. #define int long long
  15. const int inf=1e18;
  16. #define pii pair<int, int>
  17. #define f first
  18. #define s second
  19. #define mp make_pair
  20. #define FOR(i, n) for(int i=1;i<=n;i++)
  21. #define TRACE(x) cerr << #x << " = " << x << endl
  22. //Trace prints the name of the variable and the value.
  23. //SET QUESTION BRUTE.
  24. int arr[N], n, m;
  25. signed main()
  26. {
  27. ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  28. cin>>n>>m;arr[0]=inf;
  29. for(int i=1;i<=n;i++) {cin>>arr[i];//assert(arr[i]!=arr[i-1]);
  30. }
  31. while(m--)
  32. {
  33. int ind, val;
  34. int t;cin>>t;
  35. if(t==1)
  36. { cin>>ind>>val;
  37. arr[ind]=val;
  38. assert(arr[ind]!=arr[ind-1]);
  39. if(ind!=n) assert(arr[ind]!=arr[ind+1]);
  40. }
  41. else
  42. {
  43. cin>>ind;ind--;
  44. while(ind>0&&arr[ind+1]%arr[ind]==0)
  45. {
  46. ind--;
  47. }
  48. cout<<ind+1<<endl;
  49. }
  50.  
  51. }
  52. }
Success #stdin #stdout 0s 4536KB
stdin
Standard input is empty
stdout
Standard output is empty