Submission #3225879
Source Code Expand
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define sqr(x) ((x)*(x)) #define mp make_pair #define uint unsigned #define PI pair<int,int> inline char gc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++; } #define gc getchar inline ll read(){ ll x = 0; char ch = gc(); bool positive = 1; for (; !isdigit(ch); ch = gc()) if (ch == '-') positive = 0; for (; isdigit(ch); ch = gc()) x = x * 10 + ch - '0'; return positive ? x : -x; } inline void write(ll a){ if(a<0){ a=-a; putchar('-'); } if(a>=10)write(a/10); putchar('0'+a%10); } inline void writeln(ll a){write(a); puts("");} inline void wri(ll a){write(a); putchar(' ');} inline ull rnd(){ return ((ull)rand()<<30^rand())<<4|rand()%4; } const int N=1000005,mod=1000000007; int n,ans,f[N]; ll fac[N],ni[N]; inline ll p(int a,int b){ return fac[a]*ni[a-b]%mod; } inline int ksm(ll a,int b){ int ans=1; for(;b;b>>=1){ if(b&1)ans=ans*a%mod; a=a*a%mod; } return ans; } int main(){ n=read(); for(int i=fac[0]=1;i<=n;i++)fac[i]=fac[i-1]*i%mod; ni[n]=ksm(fac[n],mod-2); for(int i=n;i;i--)ni[i-1]=ni[i]*i%mod; for(int i=(n+1)/2;i<n;i++){ f[i]=p(i-1,n-1-i)*fac[i]%mod; ans=(ans+(ll)(f[i]-f[i-1])*i)%mod; } cout<<(ans+mod)%mod<<endl; }
Submission Info
Submission Time | |
---|---|
Task | C - Painting Machines |
User | wzp |
Language | C++14 (GCC 5.4.1) |
Score | 800 |
Code Size | 1402 Byte |
Status | AC |
Exec Time | 18 ms |
Memory | 19712 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 800 / 800 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt |
All | sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 2 ms | 4352 KB |
sample_02.txt | AC | 1 ms | 4352 KB |
sample_03.txt | AC | 1 ms | 4352 KB |
sample_04.txt | AC | 3 ms | 7168 KB |
subtask_1_01.txt | AC | 1 ms | 4352 KB |
subtask_1_02.txt | AC | 16 ms | 19456 KB |
subtask_1_03.txt | AC | 14 ms | 16896 KB |
subtask_1_04.txt | AC | 15 ms | 17024 KB |
subtask_1_05.txt | AC | 9 ms | 12544 KB |
subtask_1_06.txt | AC | 7 ms | 10368 KB |
subtask_1_07.txt | AC | 9 ms | 14592 KB |
subtask_1_08.txt | AC | 4 ms | 7040 KB |
subtask_1_09.txt | AC | 7 ms | 10496 KB |
subtask_1_10.txt | AC | 9 ms | 12544 KB |
subtask_1_11.txt | AC | 12 ms | 16640 KB |
subtask_1_12.txt | AC | 18 ms | 19712 KB |
subtask_1_13.txt | AC | 18 ms | 19712 KB |
subtask_1_14.txt | AC | 18 ms | 19712 KB |
subtask_1_15.txt | AC | 17 ms | 19712 KB |
subtask_1_16.txt | AC | 17 ms | 19712 KB |