QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#21665#2817. 鸽鸽的分割lindongli2004#AC ✓1ms3780kbC++17662b2022-03-07 21:27:402022-05-08 03:53:44

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-08 03:53:44]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3780kb
  • [2022-03-07 21:27:40]
  • 提交

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;
}

詳細信息

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