传送门: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. 2018今日头条湖北省赛【A】

    [题目链接]https://www.nowcoder.com/acm/contest/104/A 这题就是很简单的几何题..md现场推了很久的cos sin仿佛像个zz.自己都想给自己一巴掌. 题意就 ...

  2. Spring Security 自定义登录页面

    SpringMVC + Spring Security,自定义登录页面登录验证 学习参考:http://www.mkyong.com/spring-security/spring-security-f ...

  3. Spark RDD基本操作

  4. coco2dx android package..

    /Users/chong/Documents/engine/cocos2d-x-3.15.1/tools/cocos2d-console/bin/cocos compile -p android -m ...

  5. 无法解析的外部符号 jpeg_std_error

    1>dlib.lib(png_loader.obj) : error LNK2001: 无法解析的外部符号 png_set_sig_bytes 1>dlib.lib(png_loader. ...

  6. 372 在O(1)时间复杂度删除链表节点

    原题网址:http://www.lintcode.com/zh-cn/problem/delete-node-in-the-middle-of-singly-linked-list/ 给定一个单链表中 ...

  7. iOS开发NSMutableArray数组越界处理

    #import "NSArray+CrashArray.h" #import <objc/runtime.h> @implementation NSObject (Un ...

  8. hexo 错误汇总

    文章目录 发布文章遇到: 发布文章的时候出现错误: 代码推送到github,hexo g -d 半天推送不上去 记录一次hexo+coding hexo s本都没问题,hexo g -d 样式并未改变 ...

  9. 简单总结Class.forName("").newinstance()和new()以及classLoader.loadClass("")的区别

    文章目录 背景 三种方法简单介绍 Class.forName("").newinstance()方式 new方式 classLoader.loadClass("" ...

  10. 关于Unity中资源打包

    资源包详细说明 Unity很智能只会打包用到的资源,比如sharedassets0.assets中的shader资源,如果场景中有OBJ用到了shader那么就会有shader打进这个包,如果没有就不 ...