CF1195D1.Submarine in the Rybinsk Sea (easy edition)
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This problem differs from the next one only in the presence of the constraint on the equal length of all numbers a1,a2,…,an. Actually, this problem is a subtask of the problem D2 from the same contest and the solution of D2 solves this subtask too.
A team of SIS students is going to make a trip on a submarine. Their target is an ancient treasure in a sunken ship lying on the bottom of the Great Rybinsk sea. Unfortunately, the students don't know the coordinates of the ship, so they asked Meshanya (who is a hereditary mage) to help them. He agreed to help them, but only if they solve his problem.
Let's denote a function that alternates digits of two numbers f(a1a2…ap−1ap,b1b2…bq−1bq), where a1…ap and b1…bq are digits of two integers written in the decimal notation without leading zeros.
In other words, the function f(x,y) alternately shuffles the digits of the numbers x and y by writing them from the lowest digits to the older ones, starting with the number y. The result of the function is also built from right to left (that is, from the lower digits to the older ones). If the digits of one of the arguments have ended, then the remaining digits of the other argument are written out. Familiarize with examples and formal definitions of the function below.
For example: $$f(1111, 2222) = 12121212$$ $$f(7777, 888) = 7787878$$ $$f(33, 44444) = 4443434$$ $$f(555, 6) = 5556$$ $$f(111, 2222) = 2121212$$
Formally,
- if p≥q then f(a1…ap,b1…bq)=a1a2…ap−q+1b1ap−q+2b2…ap−1bq−1apbq;
- if p<q then f(a1…ap,b1…bq)=b1b2…bq−pa1bq−p+1a2…ap−1bq−1apbq.
Mishanya gives you an array consisting of n integers ai. All numbers in this array are of equal length (that is, they consist of the same number of digits). Your task is to help students to calculate ∑i=1n∑j=1nf(ai,aj) modulo 998244353.
本题与下一题的唯一区别在于:所有数字 a1,a2,…,an 的位数相等。实际上,本题是同一场比赛中问题 D2 的一个子任务,而 D2 的解法同样适用于本子任务。
一支 SIS 学生队计划乘坐潜水艇进行一次探险。他们的目标是沉没在大雷宾斯克海底的一艘古船中的远古宝藏。不幸的是,学生们并不知道该船的坐标,因此他们请求梅沙尼亚(一位世袭魔法师)帮忙。他同意协助,但前提是学生们必须先解决他提出的问题。
我们定义一个函数 f(a1a2…ap−1ap,b1b2…bq−1bq),它交替拼接两个数的各位数字,其中 a1…ap 和 b1…bq 分别表示两个十进制整数(无前导零)的各位数字。
换言之,函数 f(x,y) 将数字 x 和 y 的各位数字从低位到高位(即从右向左)交替合并,且起始数字来自 y;结果本身也按从右向左(即从低位到高位)的方式构造。若某一参数的各位数字已用尽,则将另一参数剩余的各位数字直接追加。请参阅下方示例及该函数的形式化定义。
例如:
f(1111,2222)=12121212
f(7777,888)=7787878
f(33,44444)=4443434
f(555,6)=5556
f(111,2222)=2121212
形式化定义如下:
- 若 p≥q,则
f(a1…ap,b1…bq)=a1a2…ap−q+1b1ap−q+2b2…ap−1bq−1apbq; - 若 p<q,则
f(a1…ap,b1…bq)=b1b2…bq−pa1bq−p+1a2…ap−1bq−1apbq。
梅沙尼亚给你一个由 n 个整数 ai 构成的数组。该数组中所有数字的位数均相等(即它们均由相同数量的数字组成)。你的任务是帮助学生们计算
i=1∑nj=1∑nf(ai,aj)
对 998244353 取模的结果。
输入格式
The first line of the input contains a single integer n (1≤n≤100000) — the number of elements in the array. The second line of the input contains n integers a1,a2,…,an (1≤ai≤109) — the elements of the array. All numbers a1,a2,…,an are of equal length (that is, they consist of the same number of digits).
输入的第一行包含一个整数 n(1≤n≤100000)—— 表示数组中元素的个数。
输入的第二行包含 n 个整数 a1,a2,…,an(1≤ai≤109)—— 表示数组的元素。
所有数字 a1,a2,…,an 的长度相等(即它们均由相同位数的数字组成)。
输出格式
Print the answer modulo 998244353.
将答案对 998244353 取模后输出。
输入输出样例
输入#1
3 12 33 45
输出#1
26730
输入#2
2 123 456
输出#2
1115598
输入#3
1 1
输出#3
11
输入#4
5 1000000000 1000000000 1000000000 1000000000 1000000000
输出#4
265359409
输入解题思路,AI测评打分。不知道怎么写?