专栏文章
题解:P13672 [GCPC 2023] German Conference for Public Counting
P13672题解参与者 1已保存评论 0
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mioegs2j
- 此快照首次捕获于
- 2025/12/02 17:52 3 个月前
- 此快照最后确认于
- 2025/12/02 17:52 3 个月前
题解:P13672 [GCPC 2023] German Conference for Public Counting
这题有点偏思维。
思路
对于给定的数 ,不妨假设它有 位,他的最高位是 。
不难得出, 都至少要 个牌子,若 ,则 需要 个牌子。以此模拟即可。
代码
CPP#include<bits/stdc++.h>
using namespace std;
long long n, ans;
int wei(long long x){
int cnt = 0;
while(x){
x /= 10;
cnt++;
}
return cnt;
}
long long shu(int a, int b){
long long cnt = 0;
while(a--){
cnt = cnt * 10 + b;
}
return cnt;
}
int main(){
scanf("%lld", &n);
if(n < 10){
printf("%lld", n + 1);
return 0;
}
int w = wei(n), w10 = pow(10, w - 1), shou = n / w10, ans = 0;
if(n < shu(w, shou))shou--;
ans = shou * w + (10 - shou) * (w - 1);
printf("%d", ans);
return 0;
}
相关推荐
评论
共 0 条评论,欢迎与作者交流。
正在加载评论...