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的更多相关文章

  1. Codeforces #180 div2 C Parity Game

    // Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...

  2. Codeforces #541 (Div2) - E. String Multiplication(动态规划)

    Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...

  3. Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)

    Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...

  4. Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)

    Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...

  5. Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)

    Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...

  6. 【Codeforces #312 div2 A】Lala Land and Apple Trees

    # [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...

  7. Codeforces 1323 div2题解ABC

    A. Even Subset Sum Problem 签到题 #include <bits/stdc++.h> using namespace std; template <type ...

  8. codeforces#510 Div2

    pre过了三题 后来A题被hack了 B题终测挂了 两题其实都是有一个小细节没有处理好 中间C还因为cinT了一次 唉本来打的还不错的 还是太菜了 继续加油吧 A-Benches 有n张椅子 原来第i ...

  9. Codeforces #263 div2 解题报告

    比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...

  10. codeforces #round363 div2.C-Vacations (DP)

    题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits ...

随机推荐

  1. MongoDB 进程控制系列二:结束进程

    1:如果某个进程产生了异常,可以考虑将其kill掉 db.killOp(10417) db.killOp(10417/*opid*/) 等同于: db.$cmd.sys.killop.findOne( ...

  2. 【转】[Network] 计算机网络基础知识总结

    阅读目录 1. 网络层次划分 2. OSI七层网络模型 3. IP地址 4. 子网掩码及网络划分 5. ARP/RARP协议 6. 路由选择协议 7. TCP/IP协议 8. UDP协议 9. DNS ...

  3. C#调用接口注意要点 socket,模拟服务器、客户端通信 在ASP.NET Core中构建路由的5种方法

    C#调用接口注意要点   在用C#调用接口的时候,遇到需要通过调用登录接口才能调用其他的接口,因为在其他的接口需要在登录的状态下保存Cookie值才能有权限调用, 所以首先需要通过调用登录接口来保存c ...

  4. 【转】Extjs2.2.1 DateField 变形的问题解决方案

    <script> //Extjs2.2.1 DateField 变形的问题 // IE Ext.isIE9 = Ext.isIE && navigator.userAgen ...

  5. SNF快速开发平台3.0之--系统里广播的作用--迅速及时、简明扼要的把信息发送给接收者

    广播信息,即速度快捷.迅速及时.简明扼要的把信息发送给接收者. 当然在SNF快速开发平台上你也可以作为公告使用.不管当做什么使用要满足以下需求: 简单操作:页面操作简单 只需要输入内容就可以发送. 灵 ...

  6. PureFTP被动端口设置

    修改Pureftp的配置文件把 # PassivePortRange          30000 50000 把前面的#删除 重启pureftpd 注意把被动端口防火墙例外 如果是阿里云主机 安全规 ...

  7. Error loading page Domain: WebKitErrorDomain Error Code: 101

    使用 WebView 组件,loading的过程中出现这个错误. 解决方案: webVIew 里面加 renderError={ (e) => { if (e === 'WebKitErrorD ...

  8. DataTable转成List集合

    项目开发中,经常会获取到DataTable对象,如何把它转化成一个List对象呢?前几天就碰到这个问题,网上搜索整理了一个万能类,用了泛型和反射的知识.共享如下: public class Model ...

  9. pycharm启动慢 –xms -xmx相关参数设置

    Eclipse崩溃,错误提示:MyEclipse has detected that less than 5% of the 64MB of Perm Gen (Non-heap memory) sp ...

  10. SDL示例一:实现七段数码管的显示

    [时间:2017-05] [状态:Open] [关键词:sdl2,数字,七段数码管,图形显示,示例代码] 0 引言 本文是针对我的step-into-sdl2/7LedDigit的原理介绍,有兴趣的可 ...