QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#864397#9864. Coinjucason_xuWA 1ms3584kbC++14981b2025-01-20 15:59:542025-01-20 16:00:00

Judging History

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

  • [2025-01-20 16:00:00]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3584kb
  • [2025-01-20 15:59:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define rd(i,n) for(ll i=0;i<n;i++)
#define rp(i,n) for(ll i=1;i<=n;i++)
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define per(i,a,b) for(ll i=b;i>=a;i--)
#define vt vector
#define pb push_back
//#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,k;
inline int check(ll m){
	ll ans=0;
	while(m>=(__int128)k*k)m-=(m+k-1)/k,ans++;
	while(m>1){
		ll p=(m+k-1)/k,t=(p-1)*k;
		if(p==1)t=1;
		ans+=(m-t+p-1)/p;
		m-=(m-t+p-1)/p*p;
	//	cout<<m<<endl;
	}
	return ans;
}
inline void solve(){
	int res=check(n);
//	cout<<res<<endl;
//	return;
	ll l=1,r=n,mid,ans;
	while(l<=r){
		mid=(l+r)>>1;
		if(check(mid)==res){
			ans=mid,r=mid-1;
		}else l=mid+1;
	}
	cout<<ans<<'\n';
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int t;
	cin>>t;
	cin>>n>>k;
	rd(_,t)solve();
    return 0;
}
//Rain Rain Rain;

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3584kb

input:

4
6 2
8 3
10000 2
1919810 114514

output:

4
4
4
4

result:

wrong answer 2nd numbers differ - expected: '8', found: '4'