QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#203537#6423. FireworksqzzyqTL 0ms0kbC++141.6kb2023-10-06 17:59:312023-10-06 17:59:32

Judging History

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

  • [2023-10-06 17:59:32]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-10-06 17:59:31]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define maxn
#define put() putchar('\n')
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
using namespace std;
void read(int &x){
    int f=1;x=0;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
    x*=f;
}
namespace Debug{
	Tp void _debug(char* f,Ty t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,Ty x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	Tp ostream& operator<<(ostream& os,vector<Ty>& V){os<<"[";for(auto& vv:V) os<<vv<<",";os<<"]";return os;}
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
}using namespace Debug;
#define fi first
#define se second
#define mk make_pair
const int mod=1e9+7;
int power(int x,int y=mod-2) {
	int sum=1;
	while (y) {	
		if (y&1) sum=sum*x%mod;
		x=x*x%mod;y>>=1;
	}
	return sum;
}
double n,m,p;
double pw(double x,int y) {
	double sum=1;
	while (y) {
		if (y&1) sum=sum*x;
		x=x*x;y>>=1;
	}
	return sum;
}
void solve(void) {
	scanf("%lf%lf%lf",&n,&m,&p);
	p=p/10000;
	double ans=1e15,res=(1-p);
	int i;
	double sh=log2(n/m)/log2(1-p);
	for (i=1;i<=100;i++) {
		ans=min(ans,(n*i+m)/(1-res));
		res=res*(1-p);
	}
	int l=max(sh-100,1.0);
	res=pw(1-p,l);
	for (i=l;i<=l+300;i++) {
		ans=min(ans,(n*i+m)/(1-res));
		res=res*(1-p);
	}
	printf("%.9lf\n",ans);
}
// 1000153595.96685
signed main(void){
	freopen("1.in","r",stdin);
	int T;
	read(T);
	while (T--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

3
1 1 5000
1 1 1
1 2 10000

output:


result: