P1836

https://www.luogu.com.cn/problem/P1836

这是数位dp吗
这布什打表+暴力吗

#include<bits/stdc++.h>
using namespace std;
long long n;
int sum[10]={0,1,3,6,10,15,21,28,36,45};
int get(int n){
	if(n<0)return 0;
	return n;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
 	cin>>n;
	long long res=0,a=1,b=0;	
	while(n>0){
		res=res+a*(45*(n/10)+sum[get(n%10-1)])+(n%10)*(b+1);
		b=b+(n%10)*a;a*=10;
		n/=10;
	}
	cout<<res<<'\n';
	return 0;
}
posted @ 2025-07-09 19:18  yzc_is_SadBee  阅读(14)  评论(0)    收藏  举报