LibreOJ - 10202 樱花 数论,因子个数,唯一分解
作者:互联网
int prime[maxn]; int vis[maxn]; int euler_sieve(int n) { int cnt = 0; vis[1] = 1; for (int i = 2; i <= n; i++) { if (!vis[i]) prime[cnt++] = i; for (int j = 0; j < cnt; j++) { if (i * prime[j] > n) break; vis[i * prime[j]] = 1; if (i % prime[j] == 0) break; } } return cnt; } int main() { int cnt = euler_sieve(1000002); unordered_map<int, ll> mp; int n = readint(); for (int i = 1; i <= n; i++){ if (!vis[i]) { mp[i]++; continue; } ll tmp = i; for (int j = 0; j < cnt && (ll)prime[j] * prime[j] <= tmp; j++) { if (tmp % prime[j] == 0) while (tmp % prime[j] == 0) mp[prime[j]]++, tmp /= prime[j]; } if (tmp > 1) mp[tmp]++; } ll res = 1ll; for (auto it = mp.begin(); it != mp.end(); it++) res = res * ((1ll + 2 * it->second) % MOD) % MOD; Put(res); }
标签:樱花,prime,cnt,LibreOJ,int,res,vis,10202,mp 来源: https://www.cnblogs.com/hznumqf/p/13479820.html