20分求各位大佬调整TVT
查看原帖
20分求各位大佬调整TVT
778449
WPL0216楼主2025/2/5 12:31

测试点5&6 AC了

其他点全WA

样例输出为59.9414 & 0.0195312

实在没找出问题,代码注释打上我的想法了,希望各位大佬能帮帮忙,谢谢啦

#include<bits/stdc++.h>
using namespace std;
int h;//初始高度 
double sum,ans,temp;//总经过,最后一次的高度,循环中代替h 
int main(){
	cin>>h;//输入初始高度 
	temp=h;//赋上高度 
	for(int i=1;i<=10;i++){//跳十次 
        //加上跳一下的高(落+起 
		sum+=(temp+(temp/2));
		temp=temp/2;//更新下一次落的高度 
		if(i==10){//假如是最后一次 
			ans=temp;
		}
	}
	//输出答案 
	cout<<sum<<endl;
	cout<<ans<<endl;
	return 0;
}

2025/2/5 12:31
加载中...