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 ...
随机推荐
- vue Object.defineProperty Proxy 数据双向绑定
Object.defineProperty 虽然已经能够实现双向绑定了,但是他还是有缺陷的. 只能对属性进行数据劫持,所以需要深度遍历整个对象 对于数组不能监听到数据的变化 虽然 Vue 中确实能检测 ...
- 监控JVM内存使用情况,剩余空间小于2M时报警
一个简单的类,用来监控JVM内存使用情况,剩余空间小于2M时报警. import java.lang.management.ManagementFactory; import java.lang.ma ...
- Javascript框架的自定义事件(转)
很多 javascript 框架都提供了自定义事件(custom events),例如 jquery.yui 以及 dojo 都支持“document ready”事件.而部分自定义事件是源自回调(c ...
- Myloader参数说明
-d, --directory 备份文件的目录 -q, --queries-per-transaction 每次事务执行的查询数量,默认是1000 -o, --overwrite-tables 如果要 ...
- TypeError: sequence item 0: expected string, Tag found
原始代码: soup = BeautifulSoup(result, 'html.parser') content_list = soup.find_all('p', attrs={"cla ...
- SNF快速开发平台MVC-自由排序组件
1. 自由排序功能使用 在一些需要排序优先级的数据进行调整处理,如民族数据,在北方实施的时候汉族比较多,希望把汉族放在第一位.在蒙古实施项目时,蒙古族人最多把蒙古族放在第一选择位. 1.1. ...
- python工具 - alert弹框输出姓名年龄、求和
使用python自带的tkinter库进行GUI编程,完成两个功能: (1)要求用户输入姓名和年龄然后打印出来 (2)要求用户输入一个数字,然后计算1到该数字之间的和 代码部分: # 导入tkinte ...
- [APM] 2个实例+5个维度解读APM技术
为了加深EGO会员之间的相互了解,同时也为大家提供更多线上相互学习交流的机会,EGO正式启动会员群线上分享活动.本文是根据陈靖华分享主题“APM的价值”的内容整理而成. 第二期分享嘉宾:陈靖华,EGO ...
- Future 模式简介
简介 Future 模式是多线程开发中的一种常见设计模式,它的核心思想是异步调用. 比如我们在网上购物,付款后就会产生一个订单,之后你该干嘛干嘛,快递小哥会上门送货,而不必像在超市结账那样,付款后要等 ...
- vue与自定义元素的关系
你可能已经注意到 Vue.js 组件非常类似于自定义元素--它是 Web 组件规范的一部分.实际上 Vue.js 的组件语法参考了该规范.例如 Vue 组件实现了 Slot API 与 is 特性.但 ...