Created
March 17, 2015 00:38
-
-
Save na-o-ys/902899311a3983aeac56 to your computer and use it in GitHub Desktop.
SRM 652 Div1 Easy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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