Where is the Ghost | toph | solution
Difference between en1 and en2, changed 4 character(s)
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];↵
}↵
↵
~~~~~↵
↵
↵
↵
↵
↵
↵
↵
↵
↵

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English arghodatta 2026-11-27 17:26:06 4 Tiny change: ' my fast bolg, sorry if ' -> ' my fast blog. sorry if '
en1 English arghodatta 2026-11-27 15:44:39 1164 Initial revision (published)