QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#239674 | #6558. Allergen Testing | Fyind | WA | 63ms | 3380kb | C++20 | 915b | 2023-11-04 22:23:14 | 2023-11-04 22:23:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define _ <<" "<<
#define sz(x) ((int) (x).size())
typedef pair<int, int> pii;
typedef long long ll;
#define debug(x) cout<<#x<<':'<<x<<endl;
typedef unsigned long long ull;
const int maxn=1000;
ll ksm(ll a,ll n){
ll ans=1;
while(n){
if(n&1) ans=a*ans;
a=a*a;
n>>=1;
}
return ans;
}
int main(){
int T;
cin>>T;
while(T--){
ll n,d;
cin>>n>>d;
//debug(n);debug(d);
//vector<ll> a(n+1);
//a[0]=1;
if(n==1){
cout<<0<<endl;
continue;
}
if(d>=n-1){
cout<<1<<endl;
}
ll l=1,r=n;
while(l<r){
ll mid=(l+r)/2;
if(ksm(d+1,mid)>=n){
r=mid;
}
else l=mid+1;
}
cout<<l<<endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3376kb
input:
1 4 1
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 63ms
memory: 3380kb
input:
10000 1 1 1000000000000000000 1 1 1000000000000000000 1000000000000000000 1000000000000000000 26615519354743225 163142634 26615519354743225 163142634 26615519354743224 163142634 26615519354743226 163142634 847997831064072529 920867976 847997831064072529 920867976 847997831064072528 920867976 8479978...
output:
0 1000000000000000000 0 1 475058372354797464 6632947694746920 6632947694746920 21919841632936254 6632947694746920 389412607661037943 389412607661037943 639973114908005638 389412607661037943 115771522664687152 115771522664687152 45095596936117038 103877768030643865 82043553972576194 82043553972576194...
result:
wrong answer 2nd lines differ - expected: '60', found: '1000000000000000000'