当前位置: 代码迷 >> 综合 >> 2020-6-5
  详细解决方案

2020-6-5

热度:77   发布时间:2023-12-15 14:28:39.0

求1-n的最小公倍数

 

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e8+5;
const int mod = 1e9+7;
int n, cnt, p[100000];
bool vis[N];
int main()
{cin >> n;ll ans = 1;for (ll i = 2; i <= n; i++){if (!vis[i]){p[cnt++] = i;for (ll s = i; s <= n; s *= i)ans = ans*i%mod;}for (ll j = 0; j < cnt; j++){ll v = i*p[j];if (v > n) break;vis[v] = 1;if (i%p[j] == 0) break;}}cout << ans%mod;return 0;
}