Submission #9108

#TimeUsernameProblemLanguageResultExecution timeMemory
9108kcm1700Actual visible points (kriii2_AC)C++14
0 / 4
12 ms6624 KiB
#include <cstdio> #include <algorithm> using namespace std; int n,m; const int mod = 1000000007; long long fact[203000]; long long ifact[203000]; long long invs[203000]; long long counts[100003]; int main(){ invs[1] = 1; for(int i = 2; i <= 200010; i++) invs[i] = (invs[mod%i] * (mod-mod/i)) % mod; fact[0] = 1; for(int i = 1; i <= 200010; i++) fact[i] = i * fact[i-1] % mod; ifact[0] = 1; for(int i = 1; i <= 200010; i++) ifact[i] = (invs[i] * ifact[i-1]) % mod; scanf("%d%d",&n,&m); for(int i = 1; i <= 100000; i++) { counts[i] += fact[i+(n-2)] * ifact[n-1] % mod * ifact[i-1] % mod; counts[i] %= mod; for(int j = i*2; j <= 100000; j += i) { counts[j] -= counts[i]; } } long long ans = 0; for(int i = 0; i < m; i++) { int x; scanf("%d",&x); ans += counts[x]; } ans %= mod; ans += mod; ans %= mod; printf("%lld\n", ans); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...