Codeforces Round #604(Div. 2,
// https://codeforces.com/contest/1265/problem/D
/*
感觉像是遍历的思维构造题 有思路就很好做的
可以把该题想象成过山车或者山峰......
*/
#include<iostream>
#include<cstdio>
using namespace std; int n;
int cnt[5], last[5]; // last 是记录当前还有多少 0, 1, 2, 3
int ans[100005];
bool ok; int main()
{
for(int i = 0; i < 4; i++) {
scanf("%d", &cnt[i]);
n += cnt[i]; // n 就是输出的总长度
} for(int i = 0; i < 4; i++){
if(!cnt[i]) continue;
ans[1] = i; // 依次取 0, 1, 2, 3 为第一位开始
ok = true;
for(int j = 0; j < 4; j++){
last[j] = cnt[j] - (i == j); // 初始化 last
} for(int j = 2; j <= n; j++){ // 因为第一位已经放了所以从第二位开始
int p = ans[j - 1];
if(p - 1 >= 0 && last[p - 1]){ // 往小(低)处走
ans[j] = p - 1; last[p - 1]--;
}
else if(p + 1 < 4 && last[p + 1]){ // 往大(高)处走
ans[j] = p + 1; last[p + 1]--;
}
else ok = false; // 假如都不能 则当前做法不可取
}
if(ok){
printf("YES\n");
for(int i = 1; i <= n; i++){
printf("%d%c", ans[i], i == n ? '\n' : ' ');
}
break;
}
}
if(!ok) printf("NO\n"); return 0;
}
E,概率dp(目前还是不太懂
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 2e5+10;
const int mod = 998244353;
LL p[maxx],dp[maxx];
LL quick(LL a,LL b)
{
LL res=1;
while(b)
{
if(b&1)res=(res*a)%mod;
b>>=1;
a=(a*a)%mod;
}
return res;
}
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%lld",&p[i]);
//dp[i]=(dp[i-1]+1)*(pi/100)+(dp[i-1]+1+dp[i])*(1-pi/100)
for(int i=1;i<=n;i++)
dp[i]=(dp[i-1]+1)*100%mod*quick(p[i],mod-2)%mod;
printf("%lld\n",dp[n]);
return 0;
}
Codeforces Round #604(Div. 2,的更多相关文章
- Codeforces Round #604 (Div. 2) E. Beautiful Mirrors
链接: https://codeforces.com/contest/1265/problem/E 题意: Creatnx has n mirrors, numbered from 1 to n. E ...
- Codeforces Round #604 (Div. 2) D. Beautiful Sequence(构造)
链接: https://codeforces.com/contest/1265/problem/D 题意: An integer sequence is called beautiful if the ...
- Codeforces Round #604 (Div. 2) C. Beautiful Regional Contest
链接: https://codeforces.com/contest/1265/problem/C 题意: So the Beautiful Regional Contest (BeRC) has c ...
- Codeforces Round #604 (Div. 2) B. Beautiful Numbers
链接: https://codeforces.com/contest/1265/problem/B 题意: You are given a permutation p=[p1,p2,-,pn] of ...
- Codeforces Round #604 (Div. 2) A. Beautiful String
链接: https://codeforces.com/contest/1265/problem/A 题意: A string is called beautiful if no two consecu ...
- Codeforces Round #604 (Div. 2) E. Beautiful Mirrors 题解 组合数学
题目链接:https://codeforces.com/contest/1265/problem/E 题目大意: 有 \(n\) 个步骤,第 \(i\) 个步骤成功的概率是 \(P_i\) ,每一步只 ...
- Codeforces Round #604 (Div. 2) 部分题解
链接:http://codeforces.com/contest/1265 A. Beautiful String A string is called beautiful if no two con ...
- Codeforces Round #604 (Div. 2) A. Beautiful String(贪心)
题目链接:https://codeforces.com/contest/1265/problem/A 题意 给出一个由 a, b, c, ? 组成的字符串,将 ? 替换为 a, b, c 中的一个字母 ...
- Codeforces Round #604 (Div. 2) B. Beautiful Numbers(双指针)
题目链接:https://codeforces.com/contest/1265/problem/B 题意 给出大小为 $n$ 的一个排列,问对于每个 $i(1 \le i \le n)$,原排列中是 ...
随机推荐
- Dapr 运用之 Java gRPC 调用篇
JAVA GRPC 服务与调用 安装协议编译器 下载对应的版本编译器,并把路径加入到环境变量中,执行以下命令生成代码 protoc -I=$SRC_DIR --java_out=$DST_DIR $S ...
- JS基础-事件循环机制
从一道题浅说 JavaScript 的事件循环 原文链接: https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/7 ...
- mysql #1062 - Duplicate entry '2147483647' for key '*'
一.当我看到这报错的时候,第一眼是认为存在重复记录,但是找了很久没找到2147483647 二.一条条的插入数据(有一批数据),直到找到报错的数据,发现是长度超了,定义了int插入的值却有11位长,哭 ...
- hdu 6301 Distinct Values (贪心)
Distinct Values Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- IJKPlayerView设置Header播放视频的方法
播放b站视频连接的实测图 https://github.com/Rukey7/IjkPlayerView 使用库的连接 在用这个库播放b站视频连接的时候总是播放不了 检查了一下是因为b站视频连接需要验 ...
- Windows下mysql-5.7.28下载、安装、配置教程
最近需要更换mysql数据库的版本,写一篇文章,记录一下 一.下载mysql数据库 mysql的下载共有两种,一种是zip压缩文件,另一种是msi安装程序 官方5.7版本zip压缩文件下载页面 官方5 ...
- JavaScript 函数工具
组 all:布尔全等判断 const all = (arr, fn = Boolean) => arr.every(fn); all([4, 2, 3], x => x > 1); ...
- Get提交数据过大,tomcat报错,信息: Error parsing HTTP request header Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level
原因 get提交的数据过大,超过了默认值. 解决办法 get提交配置 设置tomcat的server.xml.找到我们启动的端口,一般是8080,增加maxHttpHeaderSize= " ...
- Python中通过csv的writerow输出的内容有多余的空行两种方法
第一种方法 如下生成的csv文件会有多个空行 import csv #python2可以用file替代open with open("test.csv","w" ...
- 如何利用随机数产生验证码(java基础知识)
以前我们通用的验证码都是五个不同的大小写字母,那么今天我就带大家学习一下利用Java基础怎么生成验证码.首先我们应该有一个清晰的思路:首先定义一个固定长度的数组用来存储需要生成的字母:其次生成随机数, ...