一、题目

  D1. Submarine in the Rybinsk Sea (easy edition)

二、分析

  简单版本的话,因为给定的a的长度都是定的,那么我们就无需去考虑其他的,只用计算ai的值在每个位置的贡献即可。

  因为长度是定的,如果ai在前,那么对所有的a的贡献就是在偶数位的贡献值然后乘以n即可。

  如果ai在后,那么对所有ai的贡献就是在奇数位的贡献值然后乘以n。

  将两种情况合并,其实就是求ai在每个位置下的贡献,然后乘以n。

  时间复杂度是$O(n)$

三、AC代码

 1 #include <bits/stdc++.h>
2
3 using namespace std;
4 typedef long long ll;
5 const int maxn = 1e5 + 13;
6 const int mod = 998244353;
7 int a[maxn], n;
8
9 ll fun(int data)
10 {
11 vector<int> vec;
12 while(data)
13 {
14 vec.push_back(data % 10);
15 data /= 10;
16 }
17 reverse(vec.begin(), vec.end());
18 ll ans = 0;
19 for(auto itr : vec)
20 {
21 ans = ans * 10 + itr;
22 ans = ans * 10 + itr;
23 ans %= mod;
24 }
25 ans = ans * n % mod;
26 return ans;
27 }
28
29
30 int main()
31 {
32 while(scanf("%d", &n) != EOF)
33 {
34 ll ans = 0;
35 for(int i = 0; i < n; i++)
36 {
37 scanf("%d", &a[i]);
38 }
39 ans = fun(a[0]);
40 for(int j = 1; j < n; j++)
41 {
42 ans = (ans + fun(a[j])) % mod;
43 }
44 printf("%I64d\n", ans);
45 }
46 return 0;
47 }

Codeforces Round #574 (Div. 2) D1. Submarine in the Rybinsk Sea (easy edition) 【计算贡献】的更多相关文章

  1. Codeforces Round #574 (Div. 2) D2. Submarine in the Rybinsk Sea (hard edition) 【计算贡献】

    一.题目 D2. Submarine in the Rybinsk Sea (hard edition) 二.分析 相比于简单版本,它的复杂地方在于对于不同长度,可能对每个点的贡献可能是有差异的. 但 ...

  2. Codeforces - 1195D1 - Submarine in the Rybinsk Sea (easy edition) - 水题

    https://codeforc.es/contest/1195/problem/D1 给\(n\)个等长的十进制数串,定义操作\(f(x,y)\)的结果是"从\(y\)的末尾开始一个一个交 ...

  3. Codeforces Round #574 (Div. 2)

    目录 Contest Info Solutions A. Drinks Choosing B. Sport Mafia C. Basketball Exercise D1. Submarine in ...

  4. Codeforces Round #574 (Div. 2) A~E Solution

    A. Drinks Choosing 有 $n$ 个人,每个人各有一种最喜欢的饮料,但是买饮料的时候只能同一种的两个两个买(两个一对) 学校只打算卖 $\left \lceil \frac{n}{2} ...

  5. Codeforces Round #574 (Div. 2)补题

    A. Drinks Choosing 统计每种酒有多少人偏爱他们. ki 为每种酒的偏爱人数. 输出ans = (n + 1)/2 >  Σki / 2 ? (n + 1)/2 - Σki / ...

  6. Codeforces Round #350 (Div. 2) D1. Magic Powder - 1 二分

    D1. Magic Powder - 1 题目连接: http://www.codeforces.com/contest/670/problem/D1 Description This problem ...

  7. Codeforces Round #540 (Div. 3) D1. Coffee and Coursework (Easy version) 【贪心】

    任意门:http://codeforces.com/contest/1118/problem/D1 D1. Coffee and Coursework (Easy version) time limi ...

  8. Codeforces Round #527 (Div. 3) D1. Great Vova Wall (Version 1) 【思维】

    传送门:http://codeforces.com/contest/1092/problem/D1 D1. Great Vova Wall (Version 1) time limit per tes ...

  9. Codeforces Round #542(Div. 2) D1.Toy Train

    链接:https://codeforces.com/contest/1130/problem/D1 题意: 给n个车站练成圈,给m个糖果,在车站上,要被运往某个位置,每到一个车站只能装一个糖果. 求从 ...

随机推荐

  1. Shpfile文件的字段类型说明

    Shpfile文件的字段类型设置如下表所示: 字段类型 字符 字段长度 长整型 N 9 短整型 N 4 浮点型 F 13 双精度 F 19 文本 C 50 特别需要注意的是字段长度,在导出SHP的时候 ...

  2. anaconda + pyqt5 + pycharm 安装,测试

    1. 安装sip pip install sip 2.安装pyqt5 pip install PyQt5 pip install PyQt5-tools -i http://pypi.douban.c ...

  3. HDU 4049 Tourism Planning(状压DP)题解

    题意:m个城市,n个人,让这n个人按固定顺序走遍m个城市.每个城市有一个单人票价pi.每个人在每个城市能获得vij的价值.如果多个人在同一城市,那么会额外获得价值,给出一张n * n价值表,额外价值为 ...

  4. Prometheus Monitoring Solution

    Prometheus Monitoring Solution 普罗米修斯 https://prometheus.io/ 警报 监控 增强指标和警报 领先 开源监控解决方案 https://promet ...

  5. 如何使用 js 检测控制台被用户打开了

    如何使用 js 检测控制台被用户打开了 js solutions 监听 F12 事件 监听键盘快捷键组合 Ctrl + Shift + I Option + Command + I Object.to ...

  6. Deno 1.0 & Node.js

    Deno 1.0 & Node.js A secure runtime for JavaScript and TypeScript. https://deno.land/v1 https:// ...

  7. 前端 & 技术团队 TL & 如何面试 & 如何带人

    前端 & 技术团队 TL & 如何面试 & 如何带人 面试 带人 作为 TL,深度了解你的团队非常重要,要去了解每个人的想法是什么,他的诉求是什么,他目前的状态怎么样,以及对他 ...

  8. how to get svg text tspan x,y position value in js

    how to get svg text tspan x,y position value in js <svg xmlns="http://www.w3.org/2000/svg&qu ...

  9. 根据对象,返回'&键名=值&键名=值‘形式

    Object.prototype.srcCode=function () { var str=''; for(key in this){ if (this.hasOwnProperty(key) == ...

  10. 链表、栈、队列、KMP相关知识点

    链表.栈与队列.kmp; 数组模拟单链表: 用的最多的是邻接表--就是多个单链表: 作用:存储树与图 需要明确相关定义: 为什么需要使用数组模拟链表 比使用结构体 或者类来说 速度更快 代码简洁 算法 ...