Skip to content

Instantly share code, notes, and snippets.

@na-o-ys
Created March 17, 2015 00:38
Show Gist options
  • Save na-o-ys/902899311a3983aeac56 to your computer and use it in GitHub Desktop.
Save na-o-ys/902899311a3983aeac56 to your computer and use it in GitHub Desktop.
SRM 652 Div1 Easy
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
class ThePermutationGame
{
public:
int findMin (int N)
{
int p[100010] = {};
for (int n = 1; n <= N; n++) {
int m = n;
for (int i = 2; i * i <= m; i++) {
int cnt = 0;
while (m % i == 0) {
m /= i;
cnt++;
}
p[i] = max(p[i], cnt);
}
if (m > 1) p[m] = max(p[m], 1);
}
ll ans = 1;
for (int n = 1; n <= N; n++) {
loop (p[n], i) {
ans = (ans * n) % MOD;
}
}
return ans;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment