codeforces 1195D2-Submarine in the Rybinsk Sea
传送门:QAQQAQ
题意:自己看
思路:就是一个类似于数位DP的东西。。。
统计a[i]数位分解的数在每一位出现的个数,即分两种讨论:
1.位数小于当前j,则j会出现在q+i,而且计算顺序互换会计算两遍
2.位数大于等于当前j,则j会出现在j*2-1或j*2
(比赛时光D1就调老半天,D2又太谨慎,结果E没时间做了)
代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define m_k make_pair
const int inf=(int)(2e9);
const ll INF=(ll)(5e18);
const int N=;
const ll MOD=;
ll a[N][],d[N],ans=;
int n,len[N],t[];
ll dp[N][][];
int fd(ll x,int id)
{
int ret=;
while(x)
{
a[id][++ret]=x%;
x/=;
}
return ret;
}
int main()
{
memset(t,,sizeof(t));
memset(dp,,sizeof(dp));
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%lld",&d[i]);
}
sort(d+,d+n+);
for(int i=;i<=n;i++)
{
len[i]=fd(d[i],i);
t[len[i]]++;
}
for(int i=;i<=n;i++)
{
for(int j=;j<=len[i];j++)
{
ll now=;
for(int pre=;pre<j;pre++)
{
dp[i][j][pre+j]+=t[pre]*;//前后两种都要考虑
now+=t[pre];
}
ll sum=n-now;
dp[i][j][j*]+=sum;
dp[i][j][j*-]+=sum;
}
}
ll ans=;
for(int i=;i<=n;i++)
{
for(int j=;j<=;j++)
{
ll now=;
for(int k=;k<=;k++)
{
if(k>) now=now*%MOD;
ans=(ans+a[i][j]*dp[i][j][k]%MOD*now)%MOD;
}
}
}
printf("%lld\n",ans);
return ;
}
codeforces 1195D2-Submarine in the Rybinsk Sea的更多相关文章
- Codeforces - 1195D2 - Submarine in the Rybinsk Sea (hard edition) - 组合数学
https://codeforc.es/problemset/problem/1195/D2 很明显可以看出,任意一个长度为\(l_1\)的数串\(s_1\)和任意一个长度为\(l_2\)的数串\(s ...
- Codeforces - 1195D1 - Submarine in the Rybinsk Sea (easy edition) - 水题
https://codeforc.es/contest/1195/problem/D1 给\(n\)个等长的十进制数串,定义操作\(f(x,y)\)的结果是"从\(y\)的末尾开始一个一个交 ...
- Codeforces Round #574 (Div. 2) D2. Submarine in the Rybinsk Sea (hard edition) 【计算贡献】
一.题目 D2. Submarine in the Rybinsk Sea (hard 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 Round #302 (Div. 2) B Sea and Islands
题目传送门 /* 题意:在n^n的海洋里是否有k块陆地 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 输出完k个L后,之后全部输出S:) 5 10 的例子可以是这样的: LSLS ...
- Codeforces Round #302 (Div. 2) B. Sea and Islands 构造
B. Sea and Islands Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/544/p ...
- Codeforces Round #380 (Div. 2)/729D Sea Battle 思维题
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the ...
- Codeforces Round #541 (Div. 2) A.Sea Battle
链接:https://codeforces.com/contest/1131/problem/A 题意: 给两个矩形,一个再上一个在下,求两个矩形合并的周围一圈的面积. 思路: 因为存在下面矩形宽度大 ...
- Codeforces Round #574 (Div. 2)
目录 Contest Info Solutions A. Drinks Choosing B. Sport Mafia C. Basketball Exercise D1. Submarine in ...
随机推荐
- 2019-2020 ACM-ICPC Latin American Regional Programming Contest
代码见:戳 easy: EIM medium-easy: BDFKL medium: ACJ medium-hard: H A - Algorithm Teaching 题意 给一些集合,现从每个集合 ...
- docker使用gitlab持续集成(1)
修改ssh连接端口vi /etc/ssh/sshd_config 写docker-compose.yml文件配置gitlab version: '3' services: gitlab: image: ...
- windows下执行tensorflow/models的代码显示No module named 'object_detection'
Traceback (most recent call last): File "object_detection/builders/model_builder_test.py", ...
- Java创建List、Map等集合对象的同时进行赋值操作
title: Java创建List.Map等集合对象的同时进行赋值操作 date: 2019-11-28 23:25:47 tags: JavaSE categories: JavaSE 问题简介 ...
- css---flex布局--容器
http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html?utm_source=tuicool 容器设置 新版的为display为flex ...
- CF377D Developing Game
题目链接: luogu 题目分析: 把每个人当成一个三元组\([l_i, r_i, v_i]\) 考虑每个人对哪个能力区间\([L, R]\)有贡献 应该是左端点在\([l_i, v_i]\),右端点 ...
- 怎样使用github?(转)
怎样使用github?(转) 转自: 怎样使用 GitHub? - 知乎https://www.zhihu.com/question/20070065 珊姗是个小太阳 ❤努力做最胖//bang的健身博 ...
- 使用SharpZipLib实现zip压缩
使用国外开源加压解压库ICSharpCode.SharpZipLib实现加压,该库的官方网站为http://www.icsharpcode.net/OpenSource/SharpZipLib/D ...
- PAT甲级——A1110 Complete Binary Tree【25】
Given a tree, you are supposed to tell if it is a complete binary tree. Input Specification: Each in ...
- linux内核参数sysctl.conf,TCP握手ack,洪水攻击syn,超时关闭wait(转)
http://www.xshell.net/linux/Linux_sysctl_conf.html 优化Linux内核sysctl.conf参数来提高服务器并发处理能力 Posted by 破冰 o ...