QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#810751 | #9864. Coin | nice333 | WA | 0ms | 3624kb | C++23 | 506b | 2024-12-12 10:30:32 | 2024-12-12 10:30:33 |
Judging History
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+=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;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3624kb
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'