B - Save the problem! CodeForces - 867B 构造题
2024-09-05 15:46:39
这个题目还是很简单的,很明显是一个构造题,但是早训的时候脑子有点糊涂,想到了用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 ;
}
最新文章
- 使用composer安装项目依赖
- ***CI新增记录成功后的返回值判断,是用isset还是empty
- Java遇见HTML——JSP篇之JSP基础语法
- iOS - (两个APP之间的跳转)
- 动画Animation
- hdu3555 Bomb 数位DP入门
- Java设计模式之(一)------单例模式
- 初识 .net core和vs code
- Making every developer more productive with Visual Studio 2019
- LeetCode算法题-Count Primes(Java实现)
- 自定义admin(self_admin)
- 嵌入式linux系统中,lsusb出现unable to initialize libusb: -99 解决办法 【转】
- 使用 IntraWeb (31) - IntraWeb 的 Xml 操作使用的是 NativeXml
- aop编程之前置通知
- MyBatis 多表查询
- [UE4]Text Block文字字体偏移
- 数据库操作类《SqlHelper》
- Building a Space Station---poj2031(最小生成树)
- [ucgui] 仪表盘函数
- windows下npm安装vue
热门文章
- Mysql基础知识一
- 【three.js第七课】鼠标点击事件和键盘按键事件的使用
- stand up meeting 12/4/2015 -12/6/2015
- . Number throry
- tensorflow基础--LeNet-5测试模型遇到TypeError: Failed to convert object of type <;class &#39;list&#39;>; to Tensor
- C++枚举算法
- powershell提示无法将“”项识别
- Blazor WebAssembly 3.2.0 已在塔架就位 将发射新一代前端SPA框架
- Spring5:概念
- 解决IE升级后必须以管理员运行的问题