Codeforces Round #671 (Div. 2) (A - B、D1题)
比赛链接:https://codeforces.com/contest/1419
https://codeforces.com/contest/1419/problems
A. Digit Game

Example
input
4
1
2
1
3
3
102
4
2069
output
2
1
1
2
题意:
Raze and Breach参加比赛,给定一个 \(n\) 位的数字(从高位到低位 \(14\)~ \(n\)),Raze只能标记奇数位的数字,而Breach只能标记偶数的值,如果存在当仅剩一个未标记的数字时,比赛结束。 如果最后一位数字是奇数,则Raze获胜,否则Breach获胜。
#include<bits/stdc++.h>
using namespace std;
int _, n; string s;
void solve() {
cin >> n >> s;
bool f1 = false, f2 = false;
for (int i = 0; i < n; i += 2)if ((s[i] - '0') % 2 == 1)f1 = true;
for (int i = 1; i < n; i += 2)if ((s[i] - '0') % 2 == 0)f2 = true;
if (n % 2) puts(f1 ? "1" : "2");
else puts(f2 ? "2" : "1");
}
int main() {
//freopen("in.txt", "r", stdin);
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> _; while (_--)solve();
}
B. Stairs

Example
input
4
1
8
6
1000000000000000000
output
1
2
1
30
思路:
待补
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll _, n, ans, now;
void solve() {
cin >> n;
ans = 2, now = 0;
while ((ans - 1) * ans / 2 <= n)n -= (ans - 1) * ans / 2, now++, ans *= 2;
cout << now << endl;
}
int main() {
//freopen("in.txt", "r", stdin);
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> _; while (_--)solve();
}
D1. Sage's Birthday (easy version)
https://codeforces.com/problemset/problem/1419/D1
现在有 n 个数,对 a[] 重新排序,使得好数最多
好数的定义:在数组中比相邻的两个数都小,则称为好数,当然数组最左边和最右边的数不能称之为好数
可以保证在数组 a 中,所有的数都是不相同的
观察好数定义,要在数组中相邻的两个数都小,利用样例举例
5
1 2 3 4 5 (这个时候即使乱序也没事,需要sort)
如果我们先从2开始放入b[],间隔2
会得到:
2 x 4 x 5
然后再从1开始:
2 1 4 3 5
b[]符合好数定义
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5;
int n; long long a[N + 10], b[2 * N + 1];
int main() {
//freopen("in.txt", "r", stdin);
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 1; i <= n; ++i)cin >> a[i];
sort(a + 1, a + 1 + n); int idx = 1;
cout << (n - 1) / 2 << endl;
for (int i = 2; i <= n; i += 2)b[i] = a[idx++];
for (int i = 1; i <= n; i += 2)b[i] = a[idx++];
for (int i = 1; i < idx; ++i)cout << b[i] << " ";
cout << endl;
}
Codeforces Round #671 (Div. 2) (A - B、D1题)的更多相关文章
- Codeforces Round #524 (Div. 2)(前三题题解)
这场比赛手速场+数学场,像我这样读题都读不大懂的蒟蒻表示呵呵呵. 第四题搞了半天,大概想出来了,但来不及(中途家里网炸了)查错,于是我交了两次丢了100分.幸亏这次没有掉rating. 比赛传送门:h ...
- Codeforces Round #671 (Div. 2)
比赛链接:https://codeforces.com/contest/1419 A. Digit Game 题意 给出一个 $n$ 位数,游戏规则如下: 1-indexed Raze标记奇数位 Br ...
- Codeforces Round #671 (Div. 2) B. Stairs 难度1200
题目链接: Problem - 1419B - Codeforces 题目 题意 给x个格子,你可以用这x个格子去拼成楼梯 好的楼梯的要求如下: 1. 第n列有n个格子 2. 这个楼梯的所有格子可以被 ...
- Codeforces Round #671 (Div. 2) (A~E)
Link~ 题面差评,整场都在读题 A 根据奇偶性判断一下即可. #include<bits/stdc++.h> #define ll long long #define N #defin ...
- Codeforces Round #671 (Div. 2) B. Stairs (递推)
题意:一个台阶由一些单元格组成,如果一个高度为\(n\)的台阶中有\(n\)个不相邻的正方形(如图中的样例),就称这个台阶是"好台阶",现给你\(x\)个单元格,问最多能组成多少个 ...
- Codeforces Round #426 (Div. 2)A B C题+赛后小结
最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络 ...
- Codeforces Round #243 (Div. 2) B(思维模拟题)
http://codeforces.com/contest/426/problem/B B. Sereja and Mirroring time limit per test 1 second mem ...
- Codeforces Round #340 (Div. 2) B. Chocolate 水题
B. Chocolate 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co Bob loves everyt ...
- Codeforces Round #340 (Div. 2) A. Elephant 水题
A. Elephant 题目连接: http://www.codeforces.com/contest/617/problem/A Descriptionww.co An elephant decid ...
- Codeforces Round #340 (Div. 2) D. Polyline 水题
D. Polyline 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co There are three p ...
随机推荐
- 4G打猎摄像机拆机分析
前言 收到一台4G打猎相机,官方外观及功能图片如下所示,现对该设备进行拆机及整体技术分析评估,看我们可以从中学习到什么. (一)什么是打猎相机 所谓打猎相机,也叫野外相机,专门用于野外观察和监测野生动 ...
- .NET微信网页开发相关文章教程
前言 今天我们主要总结一下.NET微信网页开发的相关文章教程. 微信网页开发详细文档可以看微信官方文档:https://developers.weixin.qq.com/doc/offiaccount ...
- MVC控制器传值到JS
1.传递整形数字 1 <script> 2 var data=@ViewBag.ID; 3 </script> 2.传递字符串 1 <script> 2 var d ...
- SQL动态化多个分组查询
现有以下三张表,分别为:diqu(地区表),zhiye(职业表),info(信息表) 最基本的分组查询 1 select dqID,jbID,COUNT(1) from info group by d ...
- [CF1034C] Region Separation
题目描述 There are $ n $ cities in the Kingdom of Autumn, numbered from $ 1 $ to $ n $ . People can trav ...
- vue-test ------class绑定
<template> <p :class="{'active':isActive}">Class样式绑定</p> <p :class=&q ...
- Tampermonkey 编写一个首页跳转的脚本
每次打开浏览器时,总是会跳到一个其他的网页上,关也关不掉,很烦,写一个脚本直接跳转 // ==UserScript== // @name 页面跳转 // @version 1.0.1 // @auth ...
- 14、Map
1.Map的定义 map是Go中的内置类型,它将一个值与一个键关联起来.可以使用相应的键检索值.Map 是一种无序的键值对的集合.Map 最重要的一点是通过 key 来快速检索数据,key 类似于索引 ...
- VA01/VA02/VA03 销售订单根据定价和步骤校验权限隐藏价格(二)
1.文档说明 1.1.内容回顾 之前发表过相关文章<VA01/VA02/VA03 销售订单根据定价和步骤校验权限隐藏价格>,本篇文章对上一篇文章做补充说明. 第一篇文章是通过拥有权限,则隐 ...
- 使用 GPT4V+AI Agent 做自动 UI 测试的探索
一.背景 从 Web 诞生之日起,UI 自动化就成了测试的难点,到现在近 30 年,一直没有有效的手段解决Web UI测试的问题,尽管发展了很多的 webdriver 驱动,图片 diff 驱动的工具 ...