-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path29 nov.cpp
More file actions
56 lines (45 loc) · 1.12 KB
/
Copy path29 nov.cpp
File metadata and controls
56 lines (45 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//{ Driver Code Starts
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
class Solution{
public:
long long int numoffbt(long long int a[], int n){
using ll = long long int ;
const ll N = 2e5 + 5 ;
vector<ll> fbt(N) ;
const ll mod = 1e9 + 7 ;
for(int i = 0 ; i<n ; i++) fbt[a[i]] = 1 ;
ll ans = 0 ;
for(int i = 0 ; i<N ; i++){
if(fbt[i] == 0) continue ;
ans = (ans + fbt[i]) % mod ;
for(int j = 2*i ; j<N ; j += i){
if((fbt[j] == 0) || (j/i > i)) continue ;
if(i != j/i)
fbt[j] = (fbt[j] + (2 * (fbt[i] * fbt[j/i]) % mod)%mod ) % mod ;
else
fbt[j] = (fbt[j] + (fbt[i] * fbt[j/i]) % mod) % mod ;
}
}
return ans ;
}
};
//{ Driver Code Starts.
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
long long int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
Solution ob;
cout<<ob.numoffbt(a,n)<<endl;
}
return 0;
}
// } Driver Code Ends