QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#21665 | #2817. 鸽鸽的分割 | lindongli2004# | AC ✓ | 1ms | 3780kb | C++17 | 662b | 2022-03-07 21:27:40 | 2022-05-08 03:53:44 |
Judging History
answer
#include<iostream>
#include<cstdio>
using namespace std;
int stk[10];
double getF(int x){
if(x<=5)return stk[x];
double res=0;
for(int i=0;i<=5;i++){
double th=1;
for(int j=0;j<=5;j++){
if(i==j)continue;
th=th*(x-j);
}
for(int j=0;j<=5;j++){
if(i==j)continue;
th=th/(1.0*(i-j));
}
// cerr<<th<<endl;
res+=stk[i]*th;
}
return res;
}
int main()
{
stk[0]=1; stk[1]=2; stk[2]=4; stk[3]=8; stk[4]=16; stk[5]=31;
int a;
while(scanf("%d",&a)!=EOF){
// unsigned long long ans=1;
if(a==1 || a==0)puts("1"); else cout<<getF(a-1)<<endl;
// for(int i=1;i<a;i++)ans=ans<<1; cout<<ans<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3780kb
input:
0 1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 61 62 63 64
output:
1 1 2 4 8 16 31 57 99 163 256 5036 27841 92171 231526 489406 523686 559737 597619 637393
result:
ok 20 lines