CodeForces Round #549 Div.2
A. The Doors
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 2e5 + ;
int N;
int Zero = , One = ;
int a[maxn], b[maxn], suma[maxn], sumb[maxn];
int num1, num2, ans; int main() {
scanf("%d", &N);
for(int i = ; i < N; i ++) {
scanf("%d", &a[i]);
if(a[i] == ) {
b[i] = ;
One ++;
}
if(a[i] == ) {
b[i] = ;
Zero ++;
}
if(i == ) suma[i] = a[i], sumb[i] = b[i];
else suma[i] = suma[i - ] + a[i], sumb[i] = sumb[i - ] + b[i];
} for(int i = ; i < N; i ++) {
if(suma[i] == One) {
num1 = i;
break;
}
}
for(int i = ; i < N; i ++) {
if(sumb[i] == Zero) {
num2 = i;
break;
}
} ans = min(num1, num2);
printf("%d\n", ans + ); return ;
}
B. Nirvana
代码:
#include <bits/stdc++.h>
using namespace std; int N; int Ans(int x) {
if(x < ) return max(, x);
return max((x % ) * Ans(x / ), * Ans(x / - ));
} int main() {
scanf("%d", &N);
printf("%d\n", Ans(N));
return ;
}
C. Queen
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 1e5 + ;
const int inf = 0x3f3f3f3f;
int N;
int root;
int vis[maxn];
vector<int> ans; int main() {
scanf("%d", &N);
for(int i = ; i <= N; i ++) {
int st, col;
scanf("%d%d", &st, &col);
if(col == ) {
if(st != -)
vis[st] = ;
vis[i] = ;
}
} for(int i = ; i <= N; i ++) {
if(vis[i] != )
ans.push_back(i);
} if(ans.size() == ) printf("-1\n");
else {
sort(ans.begin(), ans.end());
for(int i = ; i < ans.size(); i ++)
printf("%d%s", ans[i], i != ans.size() - ? " " : "\n");
} return ;
}
最近是理解能力下降???读题读不清楚???菜是原罪!!!
CodeForces Round #549 Div.2的更多相关文章
- [题解] Codeforces Round #549 (Div. 2) B. Nirvana
Codeforces Round #549 (Div. 2) B. Nirvana [题目描述] B. Nirvana time limit per test1 second memory limit ...
- Codeforces Round #549 (Div. 1)
今天试图用typora写题解 真开心 参考 你会发现有很多都是参考的..zblzbl Codeforces Round #549 (Div. 1) 最近脑子不行啦 需要cf来缓解一下 A. The B ...
- Codeforces Round #549 (Div. 2) 训练实录 (5/6)
The Doors +0 找出输入的01数列里,0或者1先出完的的下标. Nirvana +3 输入n,求1到n的数字,哪个数逐位相乘的积最大,输出最大积. 思路是按位比较,从低到高,依次把小位换成全 ...
- [ Codeforces Round #549 (Div. 2)][D. The Beatles][exgcd]
https://codeforces.com/contest/1143/problem/D D. The Beatles time limit per test 1 second memory lim ...
- Codeforces Round #549 (Div. 2) F 数形结合 + 凸包(新坑)
https://codeforces.com/contest/1143/problem/F 题意 有n条形如\(y=x^2+bx+c\)的抛物线,问有多少条抛物线上方没有其他抛物线的交点 题解 \(y ...
- Codeforces Round #549 (Div. 2) E 倍增处理按排列顺序的上一个位置
https://codeforces.com/contest/1143/problem/E 题意 p为n的一个排列,给出有m个数字的数组a,q次询问,每次询问a数组区间[l,r]中是否存在子序列为p的 ...
- Codeforces Round #549 (Div. 2) D 数学
https://codeforces.com/contest/1143/problem/D 题意 有nk个城市,第1,k+1,2k+1,...,(n-1)k+1城市有餐厅,你每次能走l距离,a为起始位 ...
- B. Nirvana Codeforces Round #549 (Div. 2) (递归dfs)
---恢复内容开始--- Kurt reaches nirvana when he finds the product of all the digits of some positive integ ...
- C. Queen Codeforces Round #549 (Div. 2) (搜索)
---恢复内容开始--- You are given a rooted tree with vertices numerated from 11 to nn . A tree is a connect ...
随机推荐
- 研发团队如何写好API接口文档
导读 背景 痛点在哪? 为什么要写接口文档? API规范 接口工具 总结 背景 随着业务的发展,支撑组的项目也是越来越多.同时,从整个支撑组项目架构体系(含运维和运营体系),我们对系统业 ...
- Java开发笔记(十八)上下求索的while循环
循环是流程控制的又一重要结构,“白天-黑夜-白天-黑夜”属于时间上的循环,古人“年复一年.日复一日”的“日出而作.日落而息”便是每天周而复始的生活.计算机程序处理循环结构时,给定一段每次都要执行的代码 ...
- Java学习笔记——判断字符Character类
常用方法 下面所说的均是静态方法,也就是可以不创建对象直接调用 例:Character.isLetter(char c); isLetter 判断参数是否为字母(不分大小写),返回结果 isDigit ...
- python爬虫项目(scrapy-redis分布式爬取房天下租房信息)
python爬虫scrapy项目(二) 爬取目标:房天下全国租房信息网站(起始url:http://zu.fang.com/cities.aspx) 爬取内容:城市:名字:出租方式:价格:户型:面积: ...
- Dynamics 365中的非交互式账号(Non-interactive User)介绍
摘要: 本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复272或者20180616可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyon ...
- 腾讯云服务器 ubuntu 设置允许root用户登录
背景:最近购买了腾讯云服务器,使用了Ubuntu Server 14.04.1 LTS 64位操作系统,腾讯云主机ubuntu系统默认用户名为ubuntu,登录服务器时每一次都是以默认账号ubuntu ...
- C#1到C#4使用委托的几种方式
using System; namespace DelegateDemo { class Program { private delegate int Cacu(string str); static ...
- UE3客户端加入DS过程
拉起DS进程 客户端将比赛地图及相关参数发送给ZoneSvr请求开赛,收到消息后,ZoneSvr会分配一个ip和端口号,并与客户端发过来的地图及其他参数,来构建一个命令行来拉起一个DS进程, DS启动 ...
- 使用Linq的泛型功能
泛型数据访问类: 业务抽象类使用数据访问类: 业务类继承业务抽象类: 使用业务类:
- 【iOS开发】Alamofire框架的使用一基本用法
Alamofire框架的使用一 —— 基本用法 对于使用Objective-C的开发者,一定非常熟悉AFNetworking这个网络框架.在苹果推出的Swift之后,AFNetworking的作者专门 ...