308943: CF1601F. Two Sorts
Memory Limit:512 MB
Time Limit:4 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Two Sorts
题意翻译
## 题目描述 有一个数列 $ \{a_1,a_2,\dots,a_n\}$是一个1~n的排列,且所有的数都按照**字典序**排序,现在给出整数 $n(1\le n\le 10^{12})$, 求 $(\sum_{i=1}^{n}((i-a_i)\mod 998244353))\mod 10^9+7$ ,注意这里的 $x\mod y$的结果为正数 ## 输入格式 一行一个正整数 $n$ ## 输出格式 一行一个非负整数,代表你的答案题目描述
Integers from $ 1 $ to $ n $ (inclusive) were sorted lexicographically (considering integers as strings). As a result, array $ a_1, a_2, \dots, a_n $ was obtained. Calculate value of $ (\sum_{i = 1}^n ((i - a_i) \mod 998244353)) \mod 10^9 + 7 $ . $ x \mod y $ here means the remainder after division $ x $ by $ y $ . This remainder is always non-negative and doesn't exceed $ y - 1 $ . For example, $ 5 \mod 3 = 2 $ , $ (-1) \mod 6 = 5 $ .输入输出格式
输入格式
The first line contains the single integer $ n $ ( $ 1 \leq n \leq 10^{12} $ ).
输出格式
Print one integer — the required sum.
输入输出样例
输入样例 #1
3
输出样例 #1
0
输入样例 #2
12
输出样例 #2
994733045
输入样例 #3
21
输出样例 #3
978932159
输入样例 #4
1000000000000
输出样例 #4
289817887