-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCOUNT NO OF BT
More file actions
31 lines (31 loc) · 983 Bytes
/
Copy pathCOUNT NO OF BT
File metadata and controls
31 lines (31 loc) · 983 Bytes
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
const long long int MOD = 1000000007;
long long int mn = INT_MAX, mx = INT_MIN;
for(int i = 0; i < n; i++){
mn = (mn > arr[i]) ? arr[i] : mn;
mx = (mx < arr[i]) ? arr[i] : mx;
}
long long int ans = 0;
int pd;
vector<bool> vis(mx+1, false);
vector<long long int> sol(mx+1, 0);
for(int i = 0; i < n; i++){
vis[arr[i]] = 1;
sol[arr[i]] = 1;
}
for(int i = mn; i <= mx; i++){
if(!vis[i]){
continue;
}
for(int j = 2; i*j <= mx && j <= i; j++){
pd = i*j;
if(!vis[pd]){
continue;
}
sol[pd] = (sol[pd] + (sol[i]*sol[j])%MOD)%MOD;
if(i != j){
sol[pd] = ( sol[pd] + (sol[i]*sol[j])%MOD)%MOD;
}
}
ans = (ans + sol[i])%MOD;
}
return ans;