传送门: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的更多相关文章

  1. Codeforces - 1195D2 - Submarine in the Rybinsk Sea (hard edition) - 组合数学

    https://codeforc.es/problemset/problem/1195/D2 很明显可以看出,任意一个长度为\(l_1\)的数串\(s_1\)和任意一个长度为\(l_2\)的数串\(s ...

  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) D2. Submarine in the Rybinsk Sea (hard edition) 【计算贡献】

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

  4. Codeforces Round #574 (Div. 2) D1. Submarine in the Rybinsk Sea (easy edition) 【计算贡献】

    一.题目 D1. Submarine in the Rybinsk Sea (easy edition) 二.分析 简单版本的话,因为给定的a的长度都是定的,那么我们就无需去考虑其他的,只用计算ai的 ...

  5. 构造 Codeforces Round #302 (Div. 2) B Sea and Islands

    题目传送门 /* 题意:在n^n的海洋里是否有k块陆地 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 输出完k个L后,之后全部输出S:) 5 10 的例子可以是这样的: LSLS ...

  6. 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 ...

  7. 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 ...

  8. Codeforces Round #541 (Div. 2) A.Sea Battle

    链接:https://codeforces.com/contest/1131/problem/A 题意: 给两个矩形,一个再上一个在下,求两个矩形合并的周围一圈的面积. 思路: 因为存在下面矩形宽度大 ...

  9. Codeforces Round #574 (Div. 2)

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

随机推荐

  1. Js_案例(电灯)

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. marktext常用快捷键使用说明

     快捷键使用 功能 快捷键 备注 X级标题 ctrl+X X∈[1~6] 加粗 Ctrl+B 标题默认加粗 倾斜 Ctrl+I 插入表格 Ctrl+T 侧边文件信息显示 Ctrl+J 删除线 Ctrl ...

  3. 8.spark Core 进阶1

        (e.g. standalone manager, Mesos, YARN)   In "cluster" mode, the framework launches the ...

  4. JVM中堆栈

    1.JVM是基于堆栈的虚拟机.JVM为每个新创建的线程都分配一个堆栈.也就是说,对于一个Java程序来说,它的运行就是通过对堆栈的操作来完成的.堆栈以帧为单位保存线程的状态.JVM对堆栈只进行两种操作 ...

  5. Controller 获取前端数据

    默认支持的类型 在controller的方法的形参中直接定义上面这些类型的参数,springmvc会自动绑定. HttpServletRequest对象 HttpServletResponse对象 H ...

  6. expect离线安装

    expect5.45.4.tar.gz和tcl8.4.11-src.tar.gz压缩包请前往以下链接下载: https://download.csdn.net/download/gangzi221/1 ...

  7. thinkphp 字段定义

    通常每个模型类是操作某个数据表,在大多数情况下,系统会自动获取当前数据表的字段信息. 系统会在模型首次实例化的时候自动获取数据表的字段信息(而且只需要一次,以后会永久缓存字段信息,除非设置不缓存或者删 ...

  8. 判断MDI窗体的子窗体是否存在

    //***************************************************************************//函 数名: CreateForm//返 回 ...

  9. springboot下自定义配置文件,并在项目里读取的方法

    首先 pom文件引入springboot文件处理器 <dependency> <groupId>org.springframework.boot</groupId> ...

  10. Xcode 5 SVN配置

    from:http://stackoverflow.com/questions/19180718/import-a-project-in-svn-from-xcode-5/19410994#19410 ...