| 比赛 |
寒假集训4 |
评测结果 |
AAAAAAAATT |
| 题目名称 |
金币 |
最终得分 |
80 |
| 用户昵称 |
PXCZM |
运行时间 |
2.541 s |
| 代码语言 |
C++ |
内存使用 |
3.57 MiB |
| 提交时间 |
2026-02-28 11:43:06 |
显示代码纯文本
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k,ans;
int a[1000000];
int main()
{
freopen("Gold_coin.in","r",stdin);
freopen("Gold_coin.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
cin>>n>>k;
if(n<=k) cout<<n<<'\n';
else
{
ans=k;
while(true)
{
ll tmp=ans;
ll tmp1=tmp/(k-1);
if(tmp%(k-1)) tmp1++;
ll tmp2=tmp1*(k-1)-tmp;
ll tmp3=k*tmp1-tmp2;
if(tmp3>n)
{
cout<<ans<<'\n';
break;
}
else ans=tmp3;
}
}
return 0;
}