QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#149356 | #2329. Greenberg Mass Comparison | sakuya726 | AC ✓ | 5ms | 3580kb | C++14 | 1.9kb | 2023-08-24 14:52:21 | 2023-08-24 14:52:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define maxn 215
#define ll long long
#define IT set<node>::iterator
#define int ll
const int mod=1e9+7;
#pragma GCC optimize(3)
#pragma -fcrossjumping
#pragma -fdefer-pop
#pragma -fmerge-constans
#pragma -fthread-jumps
#pragma -floop-optimize
#pragma -fif-conversion
#pragma -fif-conversion2
#pragma -fdelayed-branch
#pragma -fguess-branch-probability
#pragma -fcprop-registers
#pragma -fforce-mem
#pragma -foptimize-sibling-calls
#pragma -fstrength-reduce
#pragma -fgcse
#pragma -fcse-follow-jumps
#pragma -frerun-cse-after-loop
#pragma -fdelete-null-pointer-checks
#pragma -fextensive-optimizations
#pragma -fregmove
#pragma -fschedule-insns
#pragma -fsched-interblock
#pragma -fcaller-saves
#pragma -fpeephole2
#pragma -freorder-blocks
#pragma -fstrict-aliasing
#pragma -funit-at-a-time
#pragma -falign-functions
#pragma -fcrossjumping
#pragma -finline-functions
#pragma -fweb
#pragma -fgcse-after-reload
inline int read()
{
int x=0,f=1;
char c=getchar();
while(c<'0'||c>'9')
{
if(c=='-') f=-1;
c=getchar();
}
while(c<='9'&&c>='0')
{
x=(x<<1)+(x<<3)+(c^48);
c=getchar();
}
return x*f;
}
inline int max(int a,int b)
{
if(a>b) return a;
return b;
}
inline int jc(int x)
{
if(x==0) return 1;
int ans=1;
while(x) ans*=(x--),ans%=mod;
return ans;
}
inline int mul(int a,int b)
{
int sum=1;
while(b)
{
if(b&1) sum=(sum*a)%mod;
a=(a*a)%mod;
b>>=1;
}
return sum;
}
int t,n,f[maxn];
inline int C(int x,int y)
{
return jc(x)*mul(jc(y),mod-2)%mod*mul(jc(x-y),mod-2)%mod;
}
inline void pre_work()
{
f[1]=1,f[2]=2,f[3]=5;
for(rg int i=4;i<=100;++i)
{
f[i]=1;
for(rg int j=0;j<i;++j) f[i]=(f[j]*C(i-1,j)+f[i])%mod;
}
}
signed main()
{
pre_work();
t=read();
while(t--)
{
n=read();
cout<<f[n]<<endl;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 5ms
memory: 3580kb
input:
100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
output:
1 2 5 15 52 203 877 4140 21147 115975 678570 4213597 27644437 190899322 382958538 480142077 864869230 76801385 742164233 157873304 812832668 706900318 546020311 173093227 759867260 200033042 40680577 159122123 665114805 272358185 365885605 744733441 692873095 463056339 828412002 817756178 366396447 ...
result:
ok 100 lines