Codeforces - 1195D1 - Submarine in the Rybinsk Sea (easy edition) - 水题
https://codeforc.es/contest/1195/problem/D1
给\(n\)个等长的十进制数串,定义操作\(f(x,y)\)的结果是“从\(y\)的末尾开始一个一个交替放得到的数”,求\(\sum\limits_{i=1}^{n}\sum\limits_{j=1}^{n}f(a_i,a_j)\)
很明显每个第\(k\)位(从1开始)都会恰好在\(2k\)和\(2k-1\)位各贡献\(n\)次。预处理出\(pow10\)然后暴力就可以了。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005];
const ll mod=998244353;
ll ans;
ll calc(ll x){
ll res=0;
ll base=1;
while(x){
ll r=x%10ll;
res=(res+base*11ll%mod*r%mod)%mod;
x/=10;
base=(base*100ll)%mod;
}
//cout<<res<<endl;
return res%mod;
}
int main() {
#ifdef Yinku
freopen("Yinku.in", "r", stdin);
//freopen("Yinku.out", "w", stdout);
#endif // Yinku
int n;
while(~scanf("%d", &n)) {
for(int i=1;i<=n;++i){
scanf("%lld",&a[i]);
}
ans=0;
for(int i=1;i<=n;i++){
ans=(ans+calc(a[i]))%mod;
}
printf("%lld\n",ans*n%mod);
}
}
Codeforces - 1195D1 - Submarine in the Rybinsk Sea (easy edition) - 水题的更多相关文章
- Codeforces Round #574 (Div. 2) D1. Submarine in the Rybinsk Sea (easy edition) 【计算贡献】
一.题目 D1. Submarine in the Rybinsk Sea (easy edition) 二.分析 简单版本的话,因为给定的a的长度都是定的,那么我们就无需去考虑其他的,只用计算ai的 ...
- Codeforces - 1195D2 - Submarine in the Rybinsk Sea (hard edition) - 组合数学
https://codeforc.es/problemset/problem/1195/D2 很明显可以看出,任意一个长度为\(l_1\)的数串\(s_1\)和任意一个长度为\(l_2\)的数串\(s ...
- Codeforces Round #574 (Div. 2) D2. Submarine in the Rybinsk Sea (hard edition) 【计算贡献】
一.题目 D2. Submarine in the Rybinsk Sea (hard edition) 二.分析 相比于简单版本,它的复杂地方在于对于不同长度,可能对每个点的贡献可能是有差异的. 但 ...
- Codeforces 148D 一袋老鼠 Bag of mice | 概率DP 水题
除非特别忙,我接下来会尽可能翻译我做的每道CF题的题面! Codeforces 148D 一袋老鼠 Bag of mice | 概率DP 水题 题面 胡小兔和司公子都认为对方是垃圾. 为了决出谁才是垃 ...
- Codeforces Testing Round #8 B. Sheldon and Ice Pieces 水题
题目链接:http://codeforces.com/problemset/problem/328/B 水题~ #include <cstdio> #include <cstdlib ...
- Codeforces Round #290 (Div. 2) A. Fox And Snake 水题
A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...
- Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题
A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...
- Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题
B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...
- Codeforces Round #368 (Div. 2) A. Brain's Photos 水题
A. Brain's Photos 题目连接: http://www.codeforces.com/contest/707/problem/A Description Small, but very ...
随机推荐
- 使用Nginx代理和转发Websocket连接
1.Websocket 简介 WebSocket协议是基于TCP的一种新的网络协议.它实现了浏览器与服务器全双工(full-duplex)通信——允许服务器主动发送信息给客户端. 2.Nginx 简介 ...
- linux强制用户下线命令
linux强制用户下线命令 前提:必须是root权限操作:(1)使用who查看目前有哪些用户登录了服务器,见下图(2)使用pkill -kill -t pts/1命令踢出第一个用户.命令解释:pt ...
- nodejs npm资料
安装淘宝的 cnpm : npm install --global cnpm 不想安装 cnpm 又想使用淘宝的服务器来下载 : npm install jquery --registry=http ...
- case_when
select sname,score,case when score>=20 and score<30 then 20when score>=30 and score<40 t ...
- 【串线篇】spring boot全面接管springMvc
一.Spring MVC auto-configuration Spring Boot 自动配置好了SpringMVC 以下是SpringBoot对SpringMVC的默认配置:(WebMvcAutoC ...
- CBV和FBV
CBV和FBV 刚开始写的视图都是基于函数版本的,称为FBV,后来写了一个NB的叫CBV,就是基于类的 FBV就是在URL中的一个路径对应一个函数 urlpatterns = [ url(r'^adm ...
- 在idea中把springboot项目打成jar包遇到的问题(没有主清单属性)
正确的姿势:<plugin> <groupId>org.springframework.boot</groupId> <artifactId>sprin ...
- Python_010(迭代器)
一.函数名的运用 1.函数名的内存地址 def func(): print("英雄联盟") print(func) #输出结果: <function func at 0x00 ...
- 【HDOJ6627】equation(模拟)
题意:给定n,整数序列a和b,整数C,求所有成立的x n<=1e5,1<=a[i]<=1e3,-1e3<=b[i]<=1e3,1<=C<=1e9 思路: 大概 ...
- Delphi 清理程序内存
procedure ClearMemory;begin if Win32Platform = VER_PLATFORM_WIN32_NT then begin ...