Submission #1241486
Source Code Expand
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <stack> #include <queue> #include <cctype> #define rep(i, m, n) for(int i = m;i < n;i++) #define repr(i, n) for(int i = n;i >= 0;i--) #define ll long long #define ull unsigned long long #define push(a) push_back(a) #define pop(a) pop_back(a) #define debug(x) cout<<#x<<": "<<x<<endl #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define INF 999999999 #define N_MAX 1000 using namespace std; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef pair<int, P> PP; typedef pair<ll, LP> LPP; int dy[]={0, 0, 1, -1, 0}; int dx[]={1, -1, 0, 0, 0}; bool pn_flag[N_MAX]; //prime_numbers(素数)の略。配列のfalseのところが素数となる。 int exp[N_MAX]; //exponent(べき指数)の略 素数のべき指数の数を保存する変数。 void pn(int n){ //prime_numbers(素数)の略 for(int i = 2; i <=n; i++){ for(int j = 2*i; j <=n; j+=i){ pn_flag[j] = 1; } } } ull fpn(int N){//factorization_in_prime_numbers(素因数分解)の略 ull cnt=1; int n; for(int i = 2; i <= N; i++){ n = i; for(int j = 2; j <= i; j++){ if(pn_flag[j] == 0){ while(n%j == 0){ n /= j; exp[j]++; } } } } for(int i = 2; i <= N; i++){ if(exp[i] != 0){ exp[i]++; cnt *= exp[i]; cnt %= 1000000007; } } return cnt; } int main(){ int N; ull cnt=0; cin >> N; pn(N); cout << endl; cnt = fpn(N); cout << cnt << endl; }
Submission Info
Submission Time | |
---|---|
Task | C - Factors of Factorial |
User | thedekopin0108 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1628 Byte |
Status | AC |
Exec Time | 3 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_certain_01.txt, subtask_1_certain_02.txt, subtask_1_certain_03.txt, subtask_1_certain_04.txt, subtask_1_rand_01.txt, subtask_1_rand_02.txt, subtask_1_rand_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 1 ms | 256 KB |
sample_02.txt | AC | 1 ms | 256 KB |
sample_03.txt | AC | 3 ms | 256 KB |
subtask_1_certain_01.txt | AC | 1 ms | 256 KB |
subtask_1_certain_02.txt | AC | 1 ms | 256 KB |
subtask_1_certain_03.txt | AC | 3 ms | 256 KB |
subtask_1_certain_04.txt | AC | 3 ms | 256 KB |
subtask_1_rand_01.txt | AC | 2 ms | 256 KB |
subtask_1_rand_02.txt | AC | 2 ms | 256 KB |
subtask_1_rand_03.txt | AC | 1 ms | 256 KB |