cf1088C Ehab and a 2-operation task (构造)
题意:给一个数列,你可以进行至多n+1次操作,每次给一个前缀对某数取模或者加某数,使得最后数列严格单增
考虑到因为是前缀和而且还不能加负数,光靠加是不能让前面的小于后面的
所以要让他先在模某数意义下单增,最后再模一下
先钦定好mod,然后从后往前做,这时候a[i]已经定下来,只要给前i个加上某数使得(a[i-1]-a[i])%mod=-1即可
一共加了N次,最后还要模一次
#include<bits/stdc++.h>
#define pa pair<int,int>
#define CLR(a,x) memset(a,x,sizeof(a))
#define MP make_pair
using namespace std;
typedef long long ll;
const int maxn=1e5+; inline char gc(){
return getchar();
static const int maxs=<<;static char buf[maxs],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,,maxs,stdin),p1==p2)?EOF:*p1++;
}
inline int rd(){
int x=;char c=gc();bool neg=;
while(c<''||c>''){if(c=='-') neg=;c=gc();}
while(c>=''&&c<='') x=(x<<)+(x<<)+c-'',c=gc();
return neg?(~x+):x;
} int N;
ll a[maxn]; int main(){
//freopen("","r",stdin);
int i,j,k;
N=rd();
for(i=;i<=N;i++) a[i]=rd();
int mod=;
ll inc=;
printf("%d\n",N+);
a[N+]=;
for(i=N;i;i--){
a[i]+=inc;
int d=((a[i+]--a[i])%mod+mod)%mod;
inc+=d;a[i]+=d;
printf("1 %d %d\n",i,d);
}
printf("2 %d %d\n",N,mod);
return ;
}
cf1088C Ehab and a 2-operation task (构造)的更多相关文章
- Codeforces 959D. Mahmoud and Ehab and another array construction task(构造, 简单数论)
Codeforces 959D. Mahmoud and Ehab and another array construction task 题意 构造一个任意两个数都互质的序列,使其字典序大等于a序列 ...
- Codeforces 959 F. Mahmoud and Ehab and yet another xor task
\(>Codeforces\space959 F. Mahmoud\ and\ Ehab\ and\ yet\ another\ xor\ task<\) 题目大意 : 给出一个长度为 \ ...
- D. Mahmoud and Ehab and another array construction task 因子分界模板+贪心+数学
D. Mahmoud and Ehab and another array construction task 因子分解模板 题意 给出一个原序列a 找出一个字典序大于a的序列b,使得任意 \(i!= ...
- Codeforces 959F Mahmoud and Ehab and yet another xor task 线性基 (看题解)
Mahmoud and Ehab and yet another xor task 存在的元素的方案数都是一样的, 啊, 我好菜啊. 离线之后用线性基取check存不存在,然后计算答案. #inclu ...
- codeforces-473D Mahmoud and Ehab and another array construction task (素数筛法+贪心)
题目传送门 题目大意:先提供一个数组,让你造一个数组,这个数组的要求是 1 各元素之间都互质 2 字典序大于等于原数组 3 每一个元素都大于2 思路: 1.两个数互质的意思就是没有公因子.所以每 ...
- 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的子序列 ...
- Task构造
//原文:http://www.tuicool.com/articles/IveiQbQ 创建并且初始化Task 使用lambda表达式创建Task Task.Factory.StartNew(() ...
- 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 ...
随机推荐
- java编程规范(持续更新)
1:非空判断 错误例子: if(user.getUserName().equals("hollis")){ } 这段代码极有可能在实际运行的时候跑出NullPointerExcep ...
- python爬虫之初始scrapy
简介: Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架. 可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中. 其最初是为了 页面抓取 (更确切来说, 网络抓取 )所设 ...
- python爬虫之win7Mongod安装使用
1.下载地址:https://www.mongodb.com/download-center#community 下载完成以后下一步下一步安装. 安装路径 还需要建立一个数据库存储位置C:\mongo ...
- 【纪录】Proxychain4 使用部署以及利用 ss 加速下载操作
我觉得这个方案用来解决 linux 机器上面 apt-get 和 yum 国外源拉去取过慢的问题还是还不错的. 参看下面两个教程. Reference: https://brickyang.githu ...
- final关键字的用法
final关键字的作用 1.被final修饰的类不能被继承 报错信息:cannot inherit from final 'com.dajia.test.Animal' 2.被final修饰的方法不能 ...
- Java 学习(1) ---JDK安装和配置环境变量
一,Java 开发的第一步,就是安装JDK(Java Development ToolKit Java开发工具包) JDK 是Java开发的核心,因为它包括Java 运行环境,工具包和命令.当我们安 ...
- codeforces259B
Little Elephant and Magic Square CodeForces - 259B Little Elephant loves magic squares very much. A ...
- Nginx 用分片提示缓存效率
L:107 slice 模块 Syntax:slice size;Default: slice 0; Context:http, server, location 功能:通过range协议将大文件分解 ...
- 【C/C++】龙格库塔+亚当姆斯求解数值微分初值问题
/* 解数值微分初值问题: 龙格-库塔法求前k个初值 + 亚当姆斯法 */ #include<bits/stdc++.h> using namespace std; double f(do ...
- Django models中关于blank与null的补充说明
Django models中关于blank与null的补充说明 建立一个简易Model class Person(models.Model): GENDER_CHOICES=( (1,'Male'), ...