fork download
  1. /*triskelion*/
  2.  
  3. #include<bits/stdc++.h>
  4. #define mod 1000000007
  5. using namespace std;
  6.  
  7. typedef long long int ll;
  8. typedef long double ld;
  9.  
  10. ll a[750004]={0};
  11. ll b[750004]={0};
  12. ll c[750004]={0};
  13. int main()
  14. {
  15. ios_base::sync_with_stdio(false);
  16. //cin.tie(0);
  17. //cout.tie(0);
  18. ll t;
  19. //cout<<"test cases\n";
  20. cin>>t;
  21. while(t--)
  22. {
  23. ll i,j,ans=0,n;
  24. memset(a,0,sizeof(a));
  25. memset(b,-1,sizeof(b));
  26. memset(c,0,sizeof(c));
  27. //cout<<"n\n";
  28. cin>>n;
  29. //cout<<n<<"\n";
  30. for(i=0;i<n;i++)
  31. {
  32. cin>>a[i];
  33. b[a[i]]=i;
  34. }
  35. sort(a,a+n);
  36. for(i=n-1;i>=0;i++)
  37. {
  38. for(j=1;j*a[i]<=a[n-1];j++)
  39. {
  40. if(j==1)
  41. c[i]=1;
  42. else
  43. {
  44. if(b[a[i]*j]!=-1)
  45. c[i]+=c[b[a[i]*j]];
  46. }
  47. }
  48. }
  49. for(i=0;i<n;i++)
  50. ans=(ans+c[i])%mod;
  51. cout<<ans<<"\n";
  52. }
  53. return 0;
  54. }
  55.  
Time limit exceeded #stdin #stdout 5s 21032KB
stdin
5
5
5 10 15 20 25
stdout
Standard output is empty