B - Save the problem! CodeForces - 867B 构造题
这个题目还是很简单的,很明显是一个构造题,但是早训的时候脑子有点糊涂,想到了用1 2 来构造,
但是去算这个数的时候算错了。。。
用1 2 来构造
可以先枚举一些数来找找规律。
1 1
2 2
3 1 1 1 2 1 1
4 ....
可以发现每一个数都是 n/2+1 的可能,
所以反过来推过去就是 (s-1)*2 或者(s-1)*2+1
这个(s-1)*2+1的答案才是正确答案 因为 这个s可以==1
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <iostream>
#include <string>
#define inf 0x3f3f3f3f
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
const int maxn = 1e5 + ;
typedef long long ll; int main()
{
int n;
scanf("%d", &n);
printf("%d 2\n", (n - ) * + );
printf("1 2\n");
return ;
}
B - Save the problem! CodeForces - 867B 构造题的更多相关文章
- CodeForces 867B Save the problem
B. Save the problem! http://codeforces.com/contest/867/problem/B time limit per test 2 seconds memor ...
- Educational Codeforces Round 7 D. Optimal Number Permutation 构造题
D. Optimal Number Permutation 题目连接: http://www.codeforces.com/contest/622/problem/D Description You ...
- Codeforces 1491G - Switch and Flip(构造题)
Codeforces 题目传送门 & 洛谷题目传送门 obviously,难度高一点的构造题对我来说都是不可做题 首先考虑将排列拆成一个个置换环,也就是 \(\forall i\) 连边 \( ...
- Codeforces 482 - Diverse Permutation 构造题
这是一道蛮基础的构造题. - k +(k - 1) -(k - 2) 1 + k , 1 , k , 2, ....... ...
- CodeForces 297C Splitting the Uniqueness (脑补构造题)
题意 Split a unique array into two almost unique arrays. unique arrays指数组各个数均不相同,almost unique arrays指 ...
- BZOJ 3097: Hash Killer I【构造题,思维题】
3097: Hash Killer I Time Limit: 5 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 963 Solved: 36 ...
- CDOJ 1288 旅游的Final柱 构造题
旅游的Final柱 题目连接: http://acm.uestc.edu.cn/#/problem/show/1288 Description 柱神要去打Final啦~(≧▽≦)/~啦啦啦 柱神来到了 ...
- HDU 5355 Cake (WA后AC代码,具体解析,构造题)
题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=5355 题面: Cake Time Limit: 2000/1000 MS (Java/Others) ...
- Codeforces VP/补题小记 (持续填坑)
Codeforces VP/补题小记 1149 C. Tree Generator 给你一棵树的括号序列,每次交换两个括号,维护每次交换之后的直径. 考虑括号序列维护树的路径信息和,是将左括号看做 ...
随机推荐
- classpath和环境变量设置(转)
classpath和环境变量设置(转) 在没有设置环境变量之前,我们可以通过直接在应用程序中加带相关信息来运行我们 的程序.比如,我们可以这样开始运行一个java程序: C:\jdk1.3.1\bin ...
- 数据结构和算法(Golang实现)(19)排序算法-冒泡排序
冒泡排序 冒泡排序是大多数人学的第一种排序算法,在面试中,也是问的最多的一种,有时候还要求手写排序代码,因为比较简单. 冒泡排序属于交换类的排序算法. 一.算法介绍 现在有一堆乱序的数,比如:5 9 ...
- 【python实现卷积神经网络】批量归一化层实现
代码来源:https://github.com/eriklindernoren/ML-From-Scratch 卷积神经网络中卷积层Conv2D(带stride.padding)的具体实现:https ...
- Zipper 杭电 1501
Given three strings, you are to determine whether the third string can be formed by combining the ch ...
- python基础-json、pickle模块
json.pickle区别 总结: """ json: 1.不是所有的数据类型否可以序列化,序列化返回结果为字符串 2.不能多次对同一文件序列化 3.json数据可以跨语 ...
- windows搭建Selenium
安装 pip install -U selenium 安装浏览器驱动 用不同的浏览器需要安装不同的驱动,驱动放置的路径添加到path中. Firefox geodriver Chrome 下载驱动Ch ...
- SpringCloud(三)学习笔记之Ribbon
spring Cloud Ribbon 是一个客户端的负载均衡器,它提供对大量的HTTP和TCP客户端的访问控制. 客户端负载均衡即是当浏览器向后台发出请求的时候,客户端会向 Eureka Serve ...
- pytorch torchversion标准化数据
新旧标准差的关系
- 蒲公英 · JELLY技术周刊 Vol.03
蒲公英 · JELLY技术周刊 Vol.03 「蒲公英」期刊全新升级--JELLY技术周刊!深度挖掘业界热点动态,来自团队大咖的专业点评,带你深入了解团队研究的技术方向. 登高远眺 天高地迥,觉宇宙之 ...
- 终止过久没有返回的 Windows API 函数 ---- “CancelSynchronousIo”
Marks pending synchronous I/O operations that are issued by the specified thread as canceled. BOOL W ...