Advertisement
Guest User

Untitled

a guest
Jun 25th, 2021
2,779
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define FAST1 ios_base::sync_with_stdio(false);
  5. #define FAST2 cin.tie(NULL);
  6. #include<bits/stdc++.h>
  7. using namespace std;
  8. #define ll long long
  9. #define FAST1 ios_base::sync_with_stdio(false);
  10. #define FAST2 cin.tie(NULL);
  11.  
  12.  
  13. void solve(){
  14.     int n;
  15.     cin>>n;
  16.     int a[n];
  17.     int arr[2*n+1];
  18.     for(int i=0;i<=2*n;i++)
  19.         arr[i]=1e6;
  20.     for(int i=0;i<n;i++){
  21.         cin>>a[i];
  22.         arr[a[i]]=i+1;
  23.     }
  24.     int ct=0;
  25.     for(int i=3;i<2*n;i++){
  26.         for(int j=1;j<=sqrt(i);j++){
  27.             if(i%j==0 && i!=j*j){
  28.                 if(arr[j]+arr[i/j]==i){
  29.                     ct++;
  30.                 }
  31.             }
  32.         }
  33.     }
  34.     cout<<ct<<endl;
  35. }
  36.  
  37. int main(){
  38.     FAST1;
  39.     FAST2;
  40.     ll t=1;
  41.     cin>>t;
  42.     while(t--){
  43.         solve();
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement