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. 使用Git添加Tag的方法

    简述作为版本管理工具,Git可以对某个版本打上标签(tag),表示本版本为发行版.在发布软件,以及使用CocoaPods创建依赖库等情况时,需要对其版本使用标签注释.故简单总结一下添加tag的方式. ...

  2. Open-Source performance testing tools(From other site)

    http://www.appdynamics.com/blog/php/tools-of-the-trade-for-performance-and-load-testing/

  3. iOS 自动移除KVO观察者

    对NSObject写一个分类: #import <Foundation/Foundation.h> @interface NSObject (FMObserverHelper) - (vo ...

  4. 【C#】详解C#序列化

    目录结构: contents structure [+] 简介 控制序列化和反序列化 特性(OnSerializing.OnSerialized.OnDeserializing.OnDeseriali ...

  5. [转]三步完成Source Insight 4.0 破解安装

    下载地址有更新,之前有朋友因潜在的版权问题封禁没下到,现在更新后可正常使用了. 文末有完全清除上次安装残留的方法,需要的人可以参考. —— 更新于 2018.1.21 第一步:安装    安装sour ...

  6. Vue(九):样式绑定v-bind示例

    Vue.js class class 与 style 是 HTML 元素的属性,用于设置元素的样式,我们可以用 v-bind 来设置样式属性. Vue.js v-bind 在处理 class 和 st ...

  7. Sql2008中添加程序集(转)

    一.示例演示 1.用C# 建立数据库 CRL 项目 public partial class MyClr{    [Microsoft.SqlServer.Server.SqlFunction]    ...

  8. 6-11-N皇后问题-树和二叉树-第6章-《数据结构》课本源码-严蔚敏吴伟民版

    课本源码部分 第6章  树和二叉树 - N皇后问题 ——<数据结构>-严蔚敏.吴伟民版        源码使用说明  链接☛☛☛ <数据结构-C语言版>(严蔚敏,吴伟民版)课本 ...

  9. Fluent动网格【1】:概述

    最近总有小伙伴向我询问Fluent中的动网格问题,因此决定做一期关于Fluent动网格技术的内容. 动网格技术在流体仿真中很特殊,应用也很广.生活中能够碰到形形色色的包含有部件运动的问题,比如说我现在 ...

  10. Spring Security 认证流程

    请求之间共享SecurityContext原因: