传送门: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. Tomcat调优详解

    前言 在这里告诫一下那些感觉自己啥都会的朋友们,其实你会的可能只是皮毛,不要感觉这个东西以前已经做过了,就不想去做了 其实你还远没有达到精通的地步,遇到以前做过的东西,也要用心的再去做一遍,你可能会从 ...

  2. JS对象 返回星期方法 getDay() 返回星期,返回的是0-6的数字,0 表示星期天。如果要返回相对应“星期”,通过数组完成

    返回星期方法 getDay() 返回星期,返回的是0-6的数字,0 表示星期天.如果要返回相对应"星期",通过数组完成,代码如下: <script type="te ...

  3. JS函数 函数调用 函数定义好后,是不能自动执行的,需要调用它,直接在需要的位置写函数名。

    函数调用 函数定义好后,是不能自动执行的,需要调用它,直接在需要的位置写函数名. 第一种情况:在<script>标签内调用. <script type="text/java ...

  4. List<> ,string[]和string的相互转换

    1.string转换成string[]数组 string str = "aaa,bbb,ccc,dddd"; string[] strs = str.Split(','); 2.s ...

  5. The linux command 之软件包管理

    一.软件包系统 不同的Linux发行版用的是不同的软件包系统,多数都采用以下两种: 二.软件包系统工具 三.在库里查找软件包 四.安装库中的软件包 五.安装软件包文件中的软件包 六.删除软件包 七.更 ...

  6. js 高级 原型与原型链

    * 所有函数都有一个特别的属性: * `prototype` : 显式原型属性* 所有实例对象都有一个特别的属性: * `__proto__` : 隐式原型属性 1.  每个函数都有一个prototy ...

  7. PKUSC加油加油加油!

    一句话,把学过的掌握的甚至还未掌握的,都用上吧! 1.题目不要再再再看错了!在纸上记下关键字. 2.记得有预处理这个东西可以降低复杂度! 3.仔细阅读数据范围,取值范围的0要注意! 4.不要每次像开新 ...

  8. Java 多线程 - 原子操作AtomicInteger & CAS(Compare-and-Swap)

    原子类简介:https://www.cnblogs.com/stephen0923/p/4505902.html AtomicInteger 介绍: https://yuwenlin.iteye.co ...

  9. cocos2D-X LUA 非常简单的一个贪吃蛇案例

    --[[ 贪吃蛇 ]] local RetroSnaker = class("RetroSnaker", function() return cc.Layer:create(); ...

  10. 解决eclipse启动时出现“failed to load the jni shared library”

    如何解决启动eclipse出现failed to load the jni shared library的问题 问题描述:启动eclipse时,出现以下弹出框 此时,即表示eclispe和jdk位数不 ...