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)$,原排列中是 ...
随机推荐
- Java 复制Excel工作表
本文归纳了关于Java如何复制Excel工作表的方法,按不同复制需求,可分为: 1. 复制工作表 1.1 在同一个工作簿内复制工作表 1.2 在不同工作簿间复制工作表 2. 复制指定单元格数据 对于复 ...
- ClassNotFoundException------我有一句妈卖批一定要讲
最近在写<Writing Compilers and Interpreters>一书的代码,本来打算用vim敲代码,一来每个字母都要自己敲,而来就当练习vim,但是感觉真是太不方便了,各种 ...
- 《Java基础知识》Java内部类及其实例化
在 Java 中,允许在一个类(或方法.语句块)的内部定义另一个类,称为内部类(Inner Class),有时也称为嵌套类(Nested Class). 内部类和外层封装它的类之间存在逻辑上的所属关系 ...
- Vue与Django前后台分离跨域配置
一.跨域: 简单来说:如果前端向后端请求数据,前后端的的ip和端口都是不一致的,就是不在统一域名下,就出现了CORS跨域问题. 二.后台处理跨域 在django后台环境目录下安装插件: >: p ...
- Redis基础知识、命令以及java操作Redis
1 nosql的概念 sql:操作(关系型)数据库的标准查询语言 关系型数据库(rdbms):以关系(由行和列组成的二维表)模型为核心数据库,有表的储存系统.(mysql.oracle.sqlserv ...
- Scrum Meeting - 第七周【Alpha阶段】
每日任务内容: 本次会议为第七次Scrum Meeting会议 本次会议项目经理召开时间为20:00,在北区男生宿舍楼召开,召开时长约10分钟,探讨了本周选课网站编写的后续工作. 小组成员 本周任务 ...
- Nginx核心流程及模块介绍
Nginx核心流程及模块介绍 1. Nginx简介以及特点 Nginx简介: Nginx (engine x) 是一个高性能的web服务器和反向代理服务器,也是一个IMAP/POP3/SMTP服务器 ...
- 形如 T(n) = a * T(n/b) + f(n) 的时间复杂度计算方法
形如 T(n) = a * T(n/b) + f(n) 的时间复杂度计算方法 有一种方法叫做主方法(Master method)是用来专门计算这种形式的时间复杂度的,方法具体如下: 下边举例进行说明: ...
- 如何实现一台服务器同时运行两个php版本
有需要学习交流的友人请加入交流群的咱们一起,有问题一起交流,一起进步!前提是你是学技术的.感谢阅读! 点此加入该群jq.qq.com 假设您已经安装了Apache,为这两个项目创建了虚拟主机,并添加 ...
- Python中的四种交换数值的方法
交换两个变量的值方法,这个面试题如果只写一种当然很简单,没什么可以说的. 今天这个面试是问大家有几种办法来实现交换两个变量的值. 在没开始看具体答案前,你可以先想想看 下面分别来说说这几种方法 方法一 ...