#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll n;scanf("%lld",&n);
if(n<5)
{
printf("%d\n",n*(n-1)/2);
return 0;
}
ll i=5;
while(i*10<=n)
i*=10;
ll ans=0,sub=i;
while(i<=n)
{
ans+=min(n-(i-1),i-1);//n是最大的数,i-1是较小数中的最大数
i+=sub;
}
printf("%lld\n",ans);
return 0;
}
codeforces 899D. Shovel Sale
最新推荐文章于 2021-06-14 22:54:33 发布
本文展示了一个使用C++解决特定计数问题的程序实例。该程序通过输入一个整数n,计算并输出小于n的所有正整数中,数字递增序列的数量。采用循环结构逐步分解问题,并利用最小值函数确保计数准确性。
670

被折叠的 条评论
为什么被折叠?



