QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#810753#9864. Coinnice333WA 0ms3620kbC++23507b2024-12-12 10:31:502024-12-12 10:31:52

Judging History

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

  • [2024-12-12 10:31:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3620kb
  • [2024-12-12 10:31:50]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
    int n,k;cin>>n>>k;
    int m=1;
    int cnt=0;
    while(true){
        int p=(m%(k-1ll)==0)?(m/(k-1ll)):(m/(k-1ll)+1);
        int add=p;
        p=p*k-p;
        int m1=(p-m)/add*add+m;
        if(m1<=m)m1=m+add;
        if(m1>n)break;
        m=m1;
    }
    cout<<m<<"\n";
}
signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int t=1;
    cin>>t;
    while (t--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3620kb

input:

4
6 2
8 3
10000 2
1919810 114514

output:

4
8
8192
1832221

result:

wrong answer 4th numbers differ - expected: '1919805', found: '1832221'