[CF 676B]Pyramid of Glasses

danihao123 posted @ 2016年7月31日 12:07 in 题解 with tags codeforces 模拟 神奇题 , 777 阅读
转载请注明出处:http://danihao123.is-programmer.com/

这题可以直接模拟,貌似也可过。但复杂度很高。

我们可以直接把t个单位的酒放入第一个杯,然后向下溢出,以此类推,这样复杂度就很优秀了。

代码:

#include <iostream>
using namespace std;
const int maxn=12;
int n;
long double k[maxn][maxn];
int call(int x){
	int i,ans=0;
	long double temp;
	if(x>n)
		return 0;
	for(i=1;i<=n;i++){
		if(k[x][i]>=1.0){
			ans++;
			if(k[x][i]>1.0 && x<n){
				temp=(k[x][i]-1.0)/2;
				k[x][i]=1.0;
				k[x+1][i]+=temp;
				k[x+1][i+1]+=temp;
			}
		}
	}
	return ans+call(x+1);
}
int main(){
	cin>>n>>k[1][1];
	cout<<call(1)<<endl;
	return 0;
}
www.questionspapers 说:
Jul 02, 2023 11:50:50 AM

Professional writers have joined forces to launch the questionspapers project, which provides in-depth news coverage of current events across the nation (India). Our team is made up of professional writers and citizen www.questionspapers.in journalists with a wide range of journalism interests who are committed about delivering education updates in the public interest while maintaining transparency.Our reporting team plans to release the Education & Recruitment Update for all age groups and provide inside coverage to show the real picture of current occurrences.

KSEEB 9th Class Syl 说:
Aug 21, 2023 10:42:33 PM

Karnataka 9th Class Exam date Sheet 2024 available at Official Website, KSEEB Regulates and Supervises the System of Secondary Education in Karnataka State, It Executes and Governs Various Activities that include KSEEB 9th Class Syllabus 2024 Devising of Courses of Study, Prescribing Syllabus,This Karnataka High School Level Exam Appear Every Year More than 45 Laks of Students, Karnataka Secondary Education Students Studying Karnataka Class Revised Syllabus 2024 helps Students to Learn Logic and order and hence,Karnataka Board Class Syllabus 2024 is Designed in Accordance with the NCERT Based Guidelines and helps Students to get an Overview of the Kannada, English Medium All Subject.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter