C. Ehab and a 2-operation task
链接
[https://codeforces.com/contest/1088/problem/C]
题意
n个数,最多n+1操作,要么前i个数加x,要么前i个数对x取余,最后使得严格递增
分析
直接进行n+1次,开始所有数都加上5e5+10;
后面n次,从1开始到n对a[i]-i+1取余,就能保证严格递增
代码
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+10;
const int ma=5e5+10;
int a[N];
int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//freopen("in.txt","r",stdin);
int n;
while(cin>>n){
for(int i=1;i<=n;i++) {
cin>>a[i]; a[i]+=ma;
}
cout<<n+1<<endl;
cout<<1<<' '<<n<<' '<<ma<<endl;
for(int i=1;i<=n;i++)
cout<<2<<' '<<i<<' '<<a[i]-i+1<<endl;
}
return 0;
}
C. Ehab and a 2-operation task的更多相关文章
- Codeforces 959F Mahmoud and Ehab and yet another xor task 线性基 (看题解)
Mahmoud and Ehab and yet another xor task 存在的元素的方案数都是一样的, 啊, 我好菜啊. 离线之后用线性基取check存不存在,然后计算答案. #inclu ...
- Codeforces 959 F. Mahmoud and Ehab and yet another xor task
\(>Codeforces\space959 F. Mahmoud\ and\ Ehab\ and\ yet\ another\ xor\ task<\) 题目大意 : 给出一个长度为 \ ...
- codeforces-473D Mahmoud and Ehab and another array construction task (素数筛法+贪心)
题目传送门 题目大意:先提供一个数组,让你造一个数组,这个数组的要求是 1 各元素之间都互质 2 字典序大于等于原数组 3 每一个元素都大于2 思路: 1.两个数互质的意思就是没有公因子.所以每 ...
- Codeforces 959D. Mahmoud and Ehab and another array construction task(构造, 简单数论)
Codeforces 959D. Mahmoud and Ehab and another array construction task 题意 构造一个任意两个数都互质的序列,使其字典序大等于a序列 ...
- 959F - Mahmoud and Ehab and yet another xor task xor+dp(递推形)+离线
959F - Mahmoud and Ehab and yet another xor task xor+dp+离线 题意 给出 n个值和q个询问,询问l,x,表示前l个数字子序列的异或和为x的子序列 ...
- D. Mahmoud and Ehab and another array construction task 因子分界模板+贪心+数学
D. Mahmoud and Ehab and another array construction task 因子分解模板 题意 给出一个原序列a 找出一个字典序大于a的序列b,使得任意 \(i!= ...
- CF959D Mahmoud and Ehab and another array construction task 数学
Mahmoud has an array a consisting of n integers. He asked Ehab to find another array b of the same l ...
- Codeforces 959 D Mahmoud and Ehab and another array construction task
Discription Mahmoud has an array a consisting of n integers. He asked Ehab to find another arrayb of ...
- [CF959F]Mahmoud and Ehab and yet another xor task题解
搞n个线性基,然后每次在上一次的基础上插入读入的数,前缀和线性基,或者说珂持久化线性基. 然后一个num数组记录当时线性基里有多少数 然后每次前缀操作一下就珂以了 代码 #include <cs ...
- [CF959D]Mahmoud and Ehab and another array construction task题解
解法 非常暴力的模拟. 一开始吧\(1 -> 2 \times 10^6\)全部扔进一个set里,如果之前取得数都是与原数组相同的,那么lower_bound一下找到set中大于等于它的数,否则 ...
随机推荐
- Win10安装Redis
Redis安装 下载地址:https://github.com/MicrosoftArchive/redis/releases 下载对应的版本:这里下载Redis-x64-3.2.100 解压文件 进 ...
- Java设计模式之一 ----- 单例模式
什么是单例模式 保证一个系统中的某个类只有一个实例而且该实例易于外界访问.例如Windows界面的任务管理器就可以看做是一个单例. 单例模式的使用场景 需要频繁的进行创建和销毁的对象: 创建对象时耗时 ...
- python3的C3算法
一.基本概念 1. mro序列 MRO是一个有序列表L,在类被创建时就计算出来. 通用计算公式为: mro(Child(Base1,Base2)) = [ Child ] + merge( mro(B ...
- css固定背景图位置 实现屏幕滚动时 显示背景图不同区域
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- 前端性能优化成神之路—资源合并与压缩减少HTTP请求
资源合并与压缩减少HTTP请求的概要 资源合并与压缩减少HTTP请求主要的两个优化点是减少HTTP请求的数量和减少请求资源的大小 http协议是无状态的应用层协议,意味着每次http请求都需要建立通信 ...
- swift class的缺省基类(SwiftObject)与内存模型
Hard Constraints on Resilience The root of a class hierarchy must remain stable, at pain of invalida ...
- adb报错问题解决方法
1,报错信息:adb server version (31) doesn't match this client (40); killing 解决方法: 一: 主要是前面的31或者其他,比如32/31 ...
- Linux系统学习之文件管理
Linux目录分布通常是树形,所以它的结构又称为目录树. 一.文件和目录管理 [root@Cfhost-170820-UCNK /]# cd / [root@Cfhost-170820-UCNK /] ...
- bwdist matlab
bwdist函数用于计算元素之间的距离. 举个例子: 如果a= 0 0 0 0 0 0 1 1 1 0 0 1 ...
- Google的Flutter工具允许开发者开发跨平台应用
与大多数应用程序开发人员交谈,他们会告诉你,与iOS相比,制作Android应用程序要困难得多,也更复杂,也不那么有趣.实际上,如果你要求报价,这两种软件都将单独定价,因为它们都需要单独的开发时间和团 ...