this is my fast bolg,log. sorry if there's a mistake ↵
[problem statement ](http://toph.co/p/where-is-the-ghost)↵
[problem:]↵
↵
~~~~~↵
what is the lcm of 1 to 9 ?↵
~~~~~↵
↵
~~~~~↵
Think mod numbers of lcm!.↵
~~~~~↵
↵
↵
~~~~~↵
we need to select one or more location such that ai1*ai2*..aik %2520 = 0.↵
~~~~~↵
↵
~~~~~↵
think dp position * mod number ; ↵
~~~~~↵
↵
↵
~~~~~↵
↵
For every element, we have two choices:↵
Don't select the current element.↵
Select the current element.↵
↵
~~~~~↵
↵
~~~~~↵
#include <bits/stdc++.h>↵
using namespace std;↵
#define int long long↵
↵
int32_t main() {↵
ios_base::sync_with_stdio(false); cin.tie(0);↵
↵
int n, mod = 1e9+7;↵
cin>>n;↵
vector<int>a(n);↵
for( int &i : a)cin>>i;↵
vector<vector<int> > dp(n, vector<int> (2520, 0));↵
//dp[0][0] = 1;↵
for( int i = 0; i<n; i++){↵
dp[i][ a[i]%2520 ] = 1;↵
if( i == 0)continue;↵
for( int j= 0; j<2520; j++){↵
int tem = (j*a[i])%2520LL;↵
dp[i][ tem ] = ( dp[i][tem] + dp[i-1][j])%mod;↵
dp[i][j] = (dp[i][j]+dp[i-1][j])%mod;↵
}↵
}↵
cout<<dp[n-1][0];↵
}↵
↵
~~~~~↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
[problem statement ](http://toph.co/p/where-is-the-ghost)↵
[problem:]↵
↵
~~~~~↵
what is the lcm of 1 to 9 ?↵
~~~~~↵
↵
~~~~~↵
Think mod numbers of lcm!.↵
~~~~~↵
↵
↵
~~~~~↵
we need to select one or more location such that ai1*ai2*..aik %2520 = 0.↵
~~~~~↵
↵
~~~~~↵
think dp position * mod number ; ↵
~~~~~↵
↵
↵
~~~~~↵
↵
For every element, we have two choices:↵
Don't select the current element.↵
Select the current element.↵
↵
~~~~~↵
↵
~~~~~↵
#include <bits/stdc++.h>↵
using namespace std;↵
#define int long long↵
↵
int32_t main() {↵
ios_base::sync_with_stdio(false); cin.tie(0);↵
↵
int n, mod = 1e9+7;↵
cin>>n;↵
vector<int>a(n);↵
for( int &i : a)cin>>i;↵
vector<vector<int> > dp(n, vector<int> (2520, 0));↵
//dp[0][0] = 1;↵
for( int i = 0; i<n; i++){↵
dp[i][ a[i]%2520 ] = 1;↵
if( i == 0)continue;↵
for( int j= 0; j<2520; j++){↵
int tem = (j*a[i])%2520LL;↵
dp[i][ tem ] = ( dp[i][tem] + dp[i-1][j])%mod;↵
dp[i][j] = (dp[i][j]+dp[i-1][j])%mod;↵
}↵
}↵
cout<<dp[n-1][0];↵
}↵
↵
~~~~~↵
↵
↵
↵
↵
↵
↵
↵
↵
↵



