codeforces#525 Div2---ABC
A---Ehab and another constriction problem
https://codeforc.es/contest/1088/problem/A
题意:给定一个数$x$找两个在$1$~$x$之间的数$a$和$b$,$b$是$a$的因子,$a*b > x, \frac{a}_{b} < x$
思路:两个数都选$x$自己就可以了。在$x=1$的时候因为要求中不包含等号,所以是找不到这样的数的。
#include<iostream>
//#include<bits/stdc++.h>
#include<cstdio>
#include<cmath>
//#include<cstdlib>
//#include<cstring>
//#include<algorithm>
//#include<queue>
//#include<vector>
//#include<set>
//#include<climits>
//#include<map>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
#define pi 3.1415926535
#define inf 0x3f3f3f3f int x; int main()
{
while(scanf("%d", &x)!= EOF){ if(x == ){
printf("-1\n");
}
else{
printf("%d %d\n", x, x);
} }
return ;
}
B---Ehab and substraction
https://codeforc.es/contest/1088/problem/B
题意:给定一个序列,每次找到非零的最小值,让剩下的所有非零的数减去他。输出$k$次操作每次选择的这个数。
思路:用一个优先队列维护一下就可以了。然后用一个变量记录总的减掉的总值。
#include<iostream>
//#include<bits/stdc++.h>
#include<cstdio>
#include<cmath>
//#include<cstdlib>
//#include<cstring>
#include<algorithm>
#include<queue>
//#include<vector>
//#include<set>
//#include<climits>
//#include<map>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
#define pi 3.1415926535
#define inf 0x3f3f3f3f int n, k;
const int maxn = 1e5 + ;
int num[maxn]; int main()
{
while(scanf("%d%d", &n, &k) != EOF){
priority_queue<int, vector<int>, greater<int> >que;
int mx = -;
for(int i = ; i < n; i++){
scanf("%d", &num[i]);
mx = max(mx, num[i]);
que.push(num[i]);
} LL sub = ;
for(int i = ; i < k; i++){
if(que.empty())printf("0\n");
else{
int now = que.top();
que.pop();
now -= sub;
while(!now && !que.empty()){
now = que.top();
que.pop();
now -= sub;
}
printf("%d\n", now);
sub += (LL)now;
}
}
}
return ;
}
C---Ehab and a 2-operation task【思维好题】
https://codeforc.es/contest/1088/problem/C
题意:
给定一个序列
操作1,选定一个下标$i$,和一个数$x$,对$1$~$i$的每一个数都加上$x$
操作2,选定一个下标$i$,和一个数$x$, 对$1$~$i$的每一个数都取模$x$
最多执行n+1次操作,使得最后的序列是递增的
思路:
用到了一些取模的性质,不太熟所以没想到。
如果有$a<b$,那么$a % b = a$
如果有$a > b > a /2$,那么有$a % b = a - b$
现在要让他是递增的序列,只需要让第$i$个数是$i$就可以了。假设第$i$数是$num[i]$,只需要执行$num[i] % (num[i] - i)$
所以首先给每一个数加上一个很大的数,比如$1e5 + 5$
然后从前往后对他们取模,连负数都不需要考虑。
#include<iostream>
//#include<bits/stdc++.h>
#include<cstdio>
#include<cmath>
//#include<cstdlib>
//#include<cstring>
#include<algorithm>
#include<queue>
//#include<vector>
//#include<set>
//#include<climits>
//#include<map>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
#define pi 3.1415926535
#define inf 0x3f3f3f3f int n;
const int maxn = ;
const int add = 1e5 + ;
LL num[maxn]; int main()
{
while(scanf("%d", &n) != EOF){
for(int i = ; i < n; i++){
scanf("%lld", &num[i]);
num[i] += add;
} LL sub = ;
printf("%d\n", n + );
printf("1 %d %d\n", n, add);
for(int i = ; i < n; i++){
printf("2 %d %lld\n", i + , num[i] - i);
}
}
return ;
}
codeforces#525 Div2---ABC的更多相关文章
- Codeforces #180 div2 C Parity Game
// Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...
- Codeforces #541 (Div2) - E. String Multiplication(动态规划)
Problem Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...
- Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)
Problem Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...
- Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)
Problem Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...
- Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)
Problem Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...
- 【Codeforces #312 div2 A】Lala Land and Apple Trees
# [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...
- Codeforces 1323 div2题解ABC
A. Even Subset Sum Problem 签到题 #include <bits/stdc++.h> using namespace std; template <type ...
- codeforces#510 Div2
pre过了三题 后来A题被hack了 B题终测挂了 两题其实都是有一个小细节没有处理好 中间C还因为cinT了一次 唉本来打的还不错的 还是太菜了 继续加油吧 A-Benches 有n张椅子 原来第i ...
- Codeforces #263 div2 解题报告
比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...
- codeforces #round363 div2.C-Vacations (DP)
题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits ...
随机推荐
- chromium 使用 flash
这又是个月经问题,几乎重装一次系统就得在搞一次. 1. chromium 使用的 flash 下载 https://get.adobe.com/cn/flashplayer/otherversions ...
- C++ 获取程序编译时间
一个简单的需求,就是需要程序判断当前系统的时间是不是在程序编译之后的,如果系统当前时间在编译之前,那说明这台机器的时间是不正确的,需要终止程序运行. 因为要在程序编译时候获取时间,如果每次编译前手动修 ...
- 安装二维码、条形码识别工具zbar
参考:http://blog.csdn.net/gaofuqi/article/details/26698547 http://www.imagemagick.org/download/ImageMa ...
- Django Web开发学习笔记(5)
第五部分 Model 层 创建一个app工程.app和project的区别引用DjangoBook的说法是: 一个project包含很多个Django app以及对它们的配置. 技术上,project ...
- Swift Precondition 预处理
前言 precondition 和 assert 的格式类似,也是动态的,precondition 会造成程序的提前终止并抛出错误信息. 1.Precondition precondition 在一般 ...
- Redis资料整理
1.Redis命令參考中文简体版. 2.java操作redis.jedis使用api 3.Redis学习笔记. 4.浅谈Redis数据库的键值设计 5.Redis资料汇总专题 6.MongoDB资料汇 ...
- SNF快速开发平台3.0之--系统里广播的作用--迅速及时、简明扼要的把信息发送给接收者
广播信息,即速度快捷.迅速及时.简明扼要的把信息发送给接收者. 当然在SNF快速开发平台上你也可以作为公告使用.不管当做什么使用要满足以下需求: 简单操作:页面操作简单 只需要输入内容就可以发送. 灵 ...
- Atitit xml框架类库选型 attilax总结
Atitit xml框架类库选型 attilax总结 1. 1. XML类库可以分成2大类.标准的.这些类库通常接口和实现都是分开的1 2. Jdom 和dom4j1 2.1. 5.1. jdom1 ...
- Oracle数据导入指定表空间
1. 打开工具Oracle SQL Plus 以dba身份登录sys用户 sqlplus /nologconn sys@url as sysdba 2. 创建用户并指定表空间 使用客户端工具或者Web ...
- MobaXterm 加装cygwin软件包
上次在<MobaXterm: SSH/X远程客户端, Xmanager的最佳免费替代品>里面介绍了MobaXterm这个Windows上的便携 多合一unix工具箱,它基于Cygwin,集 ...