QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#293701#4003. Rounding MasterYunQianWA 0ms3868kbC++141.7kb2023-12-29 16:43:062023-12-29 16:43:06

Judging History

This is the latest submission verdict.

  • [2023-12-29 16:43:06]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3868kb
  • [2023-12-29 16:43:06]
  • Submitted

answer

#include<bits/stdc++.h>

#define ll long long
#define mk make_pair
#define fi first
#define int __int128
#define se second
#define double long double

using namespace std;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;(c<'0'||c>'9');c=getchar()){if(c=='-')f=-1;}
	for(;(c>='0'&&c<='9');c=getchar())x=x*10+(c&15);
	return x*f;
}

const int mod=998244353;
int ksm(int x,int y,int p=mod){
	int ans=1;
	for(int i=y;i;i>>=1,x=1ll*x*x%p)if(i&1)ans=1ll*ans*x%p;
	return ans%p;
}
int inv(int x,int p=mod){return ksm(x,p-2,p)%p;}
mt19937 rnd(time(0));
int randint(int l,int r){return rnd()%(r-l+1)+l;}
void add(int &x,int v){x+=v;if(x>=mod)x-=mod;}
void Mod(int &x){if(x>=mod)x-=mod;}
int cmod(int x){if(x>=mod)x-=mod;return x;}

void cmax(int &x,int v){x=max(x,v);}
void cmin(int &x,int v){x=min(x,v);}

int n,k;

#define EPS 1e-7
int dcmp(double x){
	if(fabs(x)<EPS)return 0;
	if(x>0)return 1;
	return -1;
}
signed main(void){

#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
#endif

	int x=1;
	n=read(),k=read();
	double L=1.5;
	auto to=[&](int t,double v){
		double tt=t;
		tt=tt*v;
		return ((int)(tt+0.5));
	};
	double R=n;
	if(k==1){
		cout<<fixed<<setprecision(6)<<R-0.5<<endl;
		return 0;
	}
	if(k>=200)return puts("1.5"),0;
	while(dcmp(R-L)>0){
		double mid=(L+R)/2.000;
		// cout<<"L,R = "<<L<<" "<<R<<endl;
		// cout<<"mid = "<<fixed<<setprecision(6)<<mid<<endl;
		int cur=x;bool chk=0;
		for(int i=1;i<=k;i++){
			cur=to(cur,mid);
			if(cur>=n){chk=1;break;}
		}
		// cout<<"chk = "<<chk<<" -> L,R = "<<L<<" "<<R<<endl;
		if(chk)R=mid;
		else L=mid;
	}
	cout<<fixed<<setprecision(6)<<L<<endl;
	// int cnt=0;
	// while(x<n)cnt++,x=to(x,L);
	// cout<<"cnt = "<<cnt<<endl;

	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3784kb

input:

18 4

output:

2.125000

result:

ok found '2.1250000', expected '2.1250000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

1 1

output:

0.500000

result:

ok found '0.5000000', expected '0.5000000', error '0.0000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

1000000000000000000 1000000000000000000

output:

1.5

result:

ok found '1.5000000', expected '1.5000000', error '0.0000000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

2 100000

output:

1.5

result:

ok found '1.5000000', expected '1.5000000', error '0.0000000'

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3560kb

input:

1 1000000000000000000

output:

1.5

result:

wrong answer 1st numbers differ - expected: '0.5000000', found: '1.5000000', error = '1.0000000'