0
点赞
收藏
分享

微信扫一扫

C. digitnum

有点d伤 2022-02-20 阅读 94

题目描述

题目链接

C++代码

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
const int mod = 998244353;

LL Pow(LL n, int k){
	LL res = 1;
	while(k){
		if(k & 1) res *= n;
		k >>= 1;
		n *= n;
	}
	return res;
}

void solve(LL n){
	string s = to_string(n);
	int len = s.size();
	LL res = 0;
	
	for(int i = 1; i <= len - 1; i ++){
		LL ed = 9 * Pow(10, i - 1);
		res = (LL)(res + (LL)(1 + ed) % mod * (ed % mod) / 2) % mod;
	}
	
	LL x = Pow(10, len - 1);
	LL ed = n - x + 1;
	res = (LL)(res + (LL)(1 + ed) % mod * (ed % mod) / 2) % mod;
	
	cout << res << '\n';
	
	return ;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	LL n;
	cin >> n;
	solve(n);
	return 0;
}
举报

相关推荐

C. Make Good

C. Manipulating History

C. Ilya and Matrix

C.开餐馆

C. Detective Task

C. Social Distance

C. Dolce Vita

0 条评论