C. Ehab and a 2-operation task (cf)

【WinSCP】不止于文件传输:多协议可视化远程管理的效率革命 本文深入解析WinSCP作为多协议可视化远程管理工具的高效应用,从文件传输到服务器管理,展现其如何通过图形界面简化复杂操作。文章涵盖安装配置、密钥认证、云存储同步及自动化脚本等实用技巧,特别强调其在SFTP、SMB、S3等多协议支持下的效率优势,是运维人员和开发者的必备工具。 阅读详情
Codeforces Round #525 (Div. 2)

Finished

 

C. Ehab and a 2-operation task

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

You're given an array aa of length nn. You can perform the following operations on it:

  • choose an index ii (1≤i≤n)(1≤i≤n), an integer xx (0≤x≤106)(0≤x≤106), and replace ajaj with aj+xaj+x for all (1≤j≤i)(1≤j≤i), which means add xx to all the elements in the prefix ending at ii.
  • choose an index ii (1≤i≤n)(1≤i≤n), an integer xx (1≤x≤106)(1≤x≤106), and replace ajaj with aj%xaj%x for all (1≤j≤i)(1≤j≤i), which means replace every element in the prefix ending at ii with the remainder after dividing it by xx.

Can you make the array strictly increasing in no more than n+1n+1 operations?

Input

The first line contains an integer nn (1≤n≤2000)(1≤n≤2000), the number of elements in the array aa.

The second line contains nn space-separated integers a1a1, a2a2, ……, anan (0≤ai≤105)(0≤ai≤105), the elements of the array aa.

Output

On the first line, print the number of operations you wish to perform. On the next lines, you should print the operations.

To print an adding operation, use the format "11 ii xx"; to print a modding operation, use the format "22 ii xx". If iior xx don't satisfy the limitations above, or you use more than n+1n+1 operations, you'll get wrong answerverdict.

Examples

input

Copy

3
1 2 3

output

Copy

0

input

Copy

3
7 6 3

output

Copy

2
1 1 1
2 2 4

Note

In the first sample, the array is already increasing so we don't need any operations.

In the second sample:

In the first step: the array becomes [8,6,3][8,6,3].

In the second step: the array becomes [0,2,3][0,2,3].

题意:用最多n+1次操作把数组变成严格递增的

 

#include <bits/stdc++.h>
using namespace std;
#define ll long long 
const int N = 1e6 + 7;

int a[N];

int b[N], c[N], d[N], cnt = 0;

int main() {
	
	int n;
	scanf ("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf ("%d", &a[i]);
	}
	
	printf ("%d\n", n+1); 
	for (int i = n; i >= 1; --i) {
		int x = (i-1) - (a[i]%n) + n;
		printf ("1 %d %d\n", i, x);
		for (int j = 1; j <= i; ++j) {
			a[j] += x;
		}
	}
	printf ("2 %d %d\n", n, n);
	/*puts("-------------");
	for (int i = 1; i <= n; ++i) {
		a[i]%=n;
		printf ("%d ", a[i]);
	}*/

	return 0;
} 

 

Codeforces 1312 E. Array Shrinking (区间dp) E. Array Shrinking time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given an array a1,a2,…,an. You can perform the following operation any number of times: Choose a pair of two neighboring equal elements ai=ai+1 (if there is at least o 立即下载

相关推荐

南邮-软件设计实验(C++版)

南邮软件设计 A档 一、分数统计 课题内容:   设计一个分数统计程序。包括学生信息的输入输出以及排序。通过该课题全面熟悉数组、字符串、文件的使用,掌握程序设计的基本方法及友好界面的设计。 课题要求: (1)输入某班级学生的姓名、分数; (2)对(1)的分数进行降幂排列并输出; (3)具有输入输出界面。 示例代码: #include<bits/stdc++.h> using...

Dainelcw 1万+

Codeforces Global Round 20补题

目录官网链接D Cyclic Rotation 官网链接 D Cyclic Rotation There is an array a of length n. You may perform the following operation any number of times: Choose two indices l and r where 1 ≤ l < r ≤ n and al=ar. Then, set a[l…r]=[al+1,al+2,…,ar,al]. You are also g

热爱计算机语言! 464

我的老款Intel MacBook Pro,如何用OpenVINO把本地大模型推理速度提升10倍?

本文详细介绍了如何在老款Intel MacBook Pro上使用OpenVINO工具包将本地大模型推理速度提升10倍。通过对比Ollama CPU原生、Transformers原生和OpenVINO优化三种方案,展示了OpenVINO在性能优化上的显著优势,并提供了从环境配置到模型转换、性能调优的完整实战指南。

weixin_28694295的博客 310

Minimizing Difference ------- CodeForces - 1244E

You are given a sequencea1,a2,…,ana1,a2,…,anconsisting ofnnintegers. You may perform the following operation on this sequence: choose any element and either increase or decrease it by one. Calc...

weixin_45177251的博客 232

用Logisim搞定华科计组实验:单总线CPU设计从微程序到硬布线的保姆级通关攻略

本文详细介绍了如何使用Logisim完成华中科技大学计算机组成原理实验中的单总线CPU设计,涵盖从微程序控制器到硬布线控制器的完整实现过程。通过MIPS指令译码器设计、微程序控制原理、状态机实现等关键步骤的保姆级教程,帮助学生掌握CPU设计的核心技能,并提供Educoder平台提交与调试的实用技巧。

weixin_30897233的博客 484

【ChatGPT实战案例】ChatGPT如何帮助产品经理高效工作?

1. 产品经理主要工作方向, 2. 具体工作中,向ChatGPT提问参考

weixin_62909516的博客 1902

关于LeetCode中Integer Replacement一题的理解

题目如下: Given a positive integer n and you can do operations as follow: If n is even, replace n with n/2.If n is odd, you can replace n with either n + 1 or n - 1. What is the minimum number of

zsy112371的专栏 673

在Visual Studio中搭建Dynamo Python开发环境,效率飞一般的增长

在Visual Studio中搭建Dynamo Python开发环境,效率飞一般的增长

BIM的乐趣 1733

Ehab and a 2-operation task【数论思想】

Ehab and a 2-operation task 题目链接(点击) You're given an arrayaaof lengthnn. You can perform the following operations on it: choose an indexii(1≤i≤n)(1≤i≤n), an integerxx(0≤x≤106)(0≤x≤106), and ...

XJHui 527

【AI开源】Understand-Anything 完整使用教程(2026最新版)

Understand-Anything是一款基于交互式知识图谱的AI学习与开发平台,能够将代码库转化为可视化知识结构,支持语义搜索、上下文问答和全流程开发。核心功能包括代码知识图谱化、AI辅助学习和多编码代理集成。支持TypeScript/JavaScript、Python等多种语言,要求Node.js 20+和16GB以上内存。提供NPM、Docker和源码三种安装方式,支持增量更新和团队知识共享。与同类产品相比,在交互式图谱、语义搜索和AI集成方面更具优势。适用于代码学习、大型项目维护和团队协作等场景。

与时俱进,开放共享 7279

Google Earth Engine:计算逐年全球潜在蒸发量(PET)的 ERA 数据

通过获取温度、湿度和降水数据,并使用Penman-Monteith公式,我们可以得到每年的潜在蒸发量。在本文中,我们将使用Google Earth Engine平台和ERA(欧洲再分析气象数据集)数据来计算逐年全球的潜在蒸发量(PET)。接下来,我们需要对ERA数据进行预处理,以获取我们需要的潜在蒸发量数据。有了温度、湿度和降水数据,我们可以使用Penman-Monteith公式来计算每年的潜在蒸发量。最后,我们可以将计算得到的潜在蒸发量数据进行可视化,以便更好地理解全球的水汽蒸发情况。

VwajAlgorithm的博客 734

Codeforces Round #535 (Div. 3) (B,C,D,E1)题解

比赛地址 B. Divisors of Two Integers Recently you have received two positive integer numbers xx and yy. You forgot them, but you remembered a shuffled list containing all divisors of xx (including 11 an...

不二君 1500

YOLOv8独家原创改进:原创自研 | 自研独家创新DSAM注意力 ,基于BiLevelRoutingAttention注意力升级

提出新颖的注意力DSAM(Deformable Bi-level SpatialAttention Module),创新度极佳,适合科研创新,效果秒杀CBAM,Channel Attention+Spartial Attention升级为新颖的Deformable Bi-level Attention+Spartial Attention

①答疑群聊服务;②YOLO大模型知识问答系统;③计算机视觉论文生成智能体; 1524

CF1088C Ehab and a 2-operation task 构造

CF1088C Ehab and a 2-operation task 构造       最简单的就是变成1~n的序列; 我们可以先加一个极大的数防止出现负数; 然后对于每一个%(a[ i ] - i); #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;algorithm&...

loooooog的博客 243

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

CF1088C - Ehab and a 2-operation task

题意:给定长度为n的数组a,可以对a进行两种操作:1.把前i个数都加上x;2.对前i个数都取模x。要求你在n+1步操作内把数组a变成完全递增的数组。 题解:把a构造成为1~n的数组,从前往后,每次对a[i]取模a[i]-i(数组从1开始输入,我的代码是从0开始),为了使前面的数不被后面的数取模影响,先把所有数都加上一个足够大的数,这样刚好n+1步。 #include <iostream...

jijiji529 190

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

cf1088C Ehab and a 2-operation task (构造)

题意:给一个数列,你可以进行至多n+1次操作,每次给一个前缀对某数取模或者加某数,使得最后数列严格单增 考虑到因为是前缀和而且还不能加负数,光靠加是不能让前面的小于后面的 所以要让他先在模某数意义下单增,最后再模一下 先钦定好mod,然后从后往前做,这时候a[i]已经定下来,只要给前i个加上某数使得(a[i-1]-a[i])%mod=-1即可 一共加了N次,最后还要模一次 ...

weixin_30391339的博客 79

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

CF-C-DIV525-Ehab and a 2-operation task-还是思维太局限了

题意: 给你一个序列,要你进行一下两种操作: 1 j x 表示从1到j的所有数都加上x(0&lt;= x &lt;= 1e5); 2 j x 表示从1到j的所有数都%x(0&lt; x &lt;= 1e5); 要你在最多在n+1步操作后,能够将改序列转化为严格单调递增序列。 输出操作步数 然后输出操作。 如果本身就满足条件,就输出0。 题目传送门 思路: 昨天真的是被好好教育了,感觉智商被虐。。。...

我们花时间收集,却忘了最重要的其实是花时间去消化 173

Codeforces1088 C. Ehab and a 2-operation task 构造递增

C https://codeforces.com/contest/1088/problem/C int n,m,k,T,minn=INF,maxx,cnt,sum,tmp,f=0,ans,f1; set<int> s; int a[maxn]; int main(){ cin>>n; rep(i,1,n){ cin>>a[i]; a[i]+=4001...

qq_40423146的博客 230

CF473 DIV2 D. Mahmoud and Ehab and another array construction task

本题基于一种贪心的思路,即:能不改就不改,但是一旦改了以后,后面的都改;具体而言,就是从前往后扫,如果当前位置的数不与前面的数冲突的话,那么我们就不改动他。但是,一旦有一个数冲突了,根据题意我们肯定要换一个更大的数,那么此时整个序列肯定就比原序列大了,那么后面的数我们肯定都要换尽可能小的。 同时,还要考虑的一个问题是,如何保证后面选的数不与前面已经选过的数冲突。方法非常暴力:我们预处理出每个数的...

HumveeA6的博客 476

cf#525 div2 C. Ehab and a 2-operation task

You’re given an array a of length n. You can perform the following operations on it: choose an index i (1≤i≤n), an integer x (0≤x≤106), and replace aj with aj+x for all (1≤j≤i), which means add x to a...

weixin_40588429的博客 308

Codeforces Round #525 (Div. 2)题解

Codeforces Round #525 (Div. 2)题解 题解 CF1088A 【Ehab and another construction problem】 依据题意枚举即可 # include <bits/stdc++.h> int main() { int x; scanf("%d", &x); for(int i = 1; i <...

weixin_34267123的博客 177

959D--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 length such that: b is lexicographically greater than or equal to a. bi ≥ 2. b is pairwise coprime...

树莓一只猪 311

Codeforces Round #525 (Div. 2) C. Ehab and a 2-operation task(数论构造)

思路来源 http://www.cnblogs.com/Dup4/p/10068891.html 题解 注意%可以起到等同于减的作用。 Solution1: 先给区间[1,n]加上一个较大的数D,比如500W, 这样ai就变为D+ai, 由于ai-i&lt;1e5,此时再对[1,i]mod (D+ai-i)时, D+ai就变为i了,而所mod数D+ai-i大于上一个数i-1...

小衣同学的博客 724

C. Ehab and a 2-operation task-构造

题意: n个数,最多n+1操作,要么前i个数加x,要么前i个数对x取余,最后使得严格递增 思路 直接进行n+1次,最终目标为 1 - n-1 的递增序列。开始所有数都取余n;后面n次。 从后面开始到对 看看 这个位置的数 与 其对应的  最终应该成为的   i-1 差距是多少 ,并且需要把后面的对他造成的影响, 算在其中,不断传递 过程中 相邻两个 之间才会有影响 ,因为 传递一次 影响...

BePosit的博客 382

Ehab and a 2-operation task

https://codeforces.com/contest/1088/problem/C 题解: 因为有n+1次机会;完全可以改变所有值,使得数组第n+1次求余后成为等差数列。 但是如果正向操作,后面的操作会影响前面已经完成的元素,所以逆向操作。 只要计入后面每次加的值就行,为了防止溢出x,所以求余一下; /* *@Author: STZG *@Language: C++ */ ...

无限迭代中...... 638
上一篇: A 小乐乐的组合数+
下一篇: F - 确定比赛名次 HDU - 1285 (拓扑排序入门)
nucleare
博客等级 码龄9年 4粉丝 149原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值