90分,求救!!!!!!!
查看原帖
90分,求救!!!!!!!
1405214
lyyz20240397楼主2024/8/4 22:38

求救!!!!!90分,一个超时:

#include <bits/stdc++.h>
using namespace std;

int main()
{
	double a, b, sum=0, s[1000005], t=1;
	cin>>a>>b;
	for(int i=b;i>=1;i--){
	
		for(int j=1;j<=i;j++)
			t*=a;
		s[i]=t;
		t=1;}
	for(int i=b;i>=1;i--)
		sum+=s[i];
	cout<<fixed<<setprecision(2)<<sum+1.0;
	return 0;
}
2024/8/4 22:38
加载中...