Submission #9112

#TimeUsernameProblemLanguageResultExecution timeMemory
9112kcm1700Actual visible points (kriii2_AC)C++14
0 / 4
20 ms56600 KiB
#include <cstdio> #include <algorithm> #include <set> using namespace std; int n,m; const int mod = 1000000007; long long fact[2030000]; long long ifact[2030000]; long long invs[2030000]; long long counts[1000030]; int main(){ invs[1] = 1; for(int i = 2; i <= 400010; i++) invs[i] = (invs[mod%i] * (mod-mod/i)) % mod; fact[0] = 1; for(int i = 1; i <= 400010; i++) fact[i] = i * fact[i-1] % mod; ifact[0] = 1; for(int i = 1; i <= 400010; i++) ifact[i] = (invs[i] * ifact[i-1]) % mod; scanf("%d%d",&n,&m); for(int i = 1; i <= 200000; i++) { counts[i] += fact[i+(n-2)] * ifact[n-1] % mod * ifact[i-1] % mod; counts[i] %= mod; for(int j = i*2; j <= 200000; j += i) { counts[j] -= counts[i]; } } set<int> tmp; long long ans = 0; for(int i = 0; i < m; i++) { int x; scanf("%d",&x); ans += counts[x]; if (tmp.insert(x).second == false) { for(;;); } } ans %= mod; ans += mod; ans %= mod; printf("%lld\n", ans); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...