Codeforces Round #525 (Div. 2)题解

题解 CF1088A 【Ehab and another construction problem】

依据题意枚举即可

# include <bits/stdc++.h>

int main()
{
int x;
scanf("%d", &x);
for(int i = 1; i <= x; i++)
for(int j = 1; j <= x; j++)
if((i % j == 0) && (j * i > x) && ((i / j) < x))
return 0 * printf("%d %d\n", i, j);
printf("-1");
return 0;
}

题解 CF1088B 【Ehab and subtraction】

这种题一上来先排序啊

然后就开始操作了

对于每一次操作,找到第一个\(\geq\)当前已经减去的数的数\(a_i\),把它减去当前已经减去数的值\(now\),然后把now更新为\(a[i]\),最后再二分(所以知道为什么要排序了吧)找下一个大于\(now\)的数,如果这个位置越界了之后就都输出\(0\)

如果还不理解就看代码

# include <bits/stdc++.h>

# define ll long long

ll a[100010];

int main()
{
ll n, k;
ll now = 0, pos = 1;
scanf("%I64d%I64d", &n, &k);
for(int i = 1; i <= n; i++)
scanf("%I64d", &a[i]);
std::sort(a + 1, a + n + 1);
a[n + 1] = 0x7f7f7f7f7f7f7f;
for(int i = 1; i <= k; i++)
{
if(pos == n + 1)
{
printf("0\n");
continue;
}
printf("%I64d\n", a[pos] - now);
now += a[pos] - now;
ll l = pos + 1, r = n + 1;
while(l < r)
{
ll mid = (l + r) >> 1;
if(a[mid] > now)
r = mid;
else l = mid + 1;
}
pos = l;
}
return 0;
}

题解 CF1088C 【Ehab and a 2-operation task】

怎么把一个序列弄成单调递增的呢?当然是把它搞成\(1 \cdots n\)啦

我们显然可以找到这样一种构造

  • 对于每个数\(a_i\),通过\(\mod a_i - i + 1\)让它变成\(i\)

这样有一个漏洞:当前的\(a_i\)小于\(i\)怎么办?

我们发现我们还有一次操作机会

所以我们把这次给\(1\)操作:把整个序列加上一个特别大的数(但要满足题目条件)

这样就刚好用了\(n+1\)次操作

# include <bits/stdc++.h>

int a[2010];

int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
scanf("%d", &a[i]);
printf("%d\n", n + 1);
printf("1 %d %d\n", n, 899999);
for(int i = 1; i <= n; i++)
{
a[i] += 899999;
printf("2 %d %d\n", i, (a[i] - i + 1));
a[i] %= (a[i] - i + 1);
}
return 0;
}

Codeforces Round #525 (Div. 2)题解的更多相关文章

  1. Codeforces Round #182 (Div. 1)题解【ABCD】

    Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...

  2. Codeforces Round #525 (Div. 2)

    Codeforces Round #525 (Div. 2) 哎,忍不住想吐槽一下,又要准备训练,又要做些无聊的事,弄得我都想退出了. 好好的训练不好么???? 只能做出两道水题,其实C题,感觉做出来 ...

  3. Codeforces Round #608 (Div. 2) 题解

    目录 Codeforces Round #608 (Div. 2) 题解 前言 A. Suits 题意 做法 程序 B. Blocks 题意 做法 程序 C. Shawarma Tent 题意 做法 ...

  4. Codeforces Round #528 (Div. 2)题解

    Codeforces Round #528 (Div. 2)题解 A. Right-Left Cipher 很明显这道题按题意逆序解码即可 Code: # include <bits/stdc+ ...

  5. Codeforces Round #466 (Div. 2) 题解940A 940B 940C 940D 940E 940F

    Codeforces Round #466 (Div. 2) 题解 A.Points on the line 题目大意: 给你一个数列,定义数列的权值为最大值减去最小值,问最少删除几个数,使得数列的权 ...

  6. Codeforces Round #677 (Div. 3) 题解

    Codeforces Round #677 (Div. 3) 题解 A. Boring Apartments 题目 题解 简单签到题,直接数,小于这个数的\(+10\). 代码 #include &l ...

  7. Codeforces Round #665 (Div. 2) 题解

    Codeforces Round #665 (Div. 2) 题解 写得有点晚了,估计都官方题解看完切掉了,没人看我的了qaq. 目录 Codeforces Round #665 (Div. 2) 题 ...

  8. Codeforces Round #160 (Div. 1) 题解【ABCD】

    Codeforces Round #160 (Div. 1) A - Maxim and Discounts 题意 给你n个折扣,m个物品,每个折扣都可以使用无限次,每次你使用第i个折扣的时候,你必须 ...

  9. Codeforces Round #383 (Div. 2) 题解【ABCDE】

    Codeforces Round #383 (Div. 2) A. Arpa's hard exam and Mehrdad's naive cheat 题意 求1378^n mod 10 题解 直接 ...

随机推荐

  1. 【Linux】一步一步学Linux——Linux发展史(01)

    目录 00. 目录 01. Linux概述 02. Linux简史 03. Linux主要特性 04. Linux之父 05. Linux相关术语 06. Linux其它 07. Linux应用领域 ...

  2. 地址解析协议(ARP)

    地址解析协议(ARP) 地址解析协议(ARP)是指网络地址和MAC地址之间的转换 当一台主机需要向另一台主机发送数据时,需要知道目的主机的ip地址外还需要知道目的主机的mac地址.源主机首先会在自己的 ...

  3. shiro是什么?

    是什么? Shiro是一个非常强大的.易于使用的.开源的.权限框架.它包括了权限校验.权限授予.会话管理.安全加密等组件. 为什么要使用shiro? 如果你是需要设计RBAC(Role Based A ...

  4. 邮件标准协议:MIME(Multipurpose Internet Mail Extensions)

    MIME(多用途互联网邮件扩展)指的是一系列电子邮件技术规范 ,主要包括 RFC 2045~2049   传统的电子邮件只能使用 ASCII 字符,导致非英文字符都不能在电子邮件中使用 而且电子邮件中 ...

  5. mouseenter 与 mouseover 区别于选择

    mouseover事件, 箭头在子元素移动会触发冒泡事件,  子元素的鼠标箭头可触父元素方法, 相反,mouseenter事件功能与mouseover类似, 但鼠标进入某个元素不会冒泡触发父元素方法. ...

  6. Golang官方log包详解

    Golang官方log包详解 以下全是代码, 详解在注释中, 请从头到尾看 // Copyright 2009 The Go Authors. All rights reserved. // Use ...

  7. iOS - 如何适配iOS10(插曲)

    升级了系统10.12beta xcode8  出现一大推问题 ,连上架APP都成了问题.只能先解决这些问题,再研究3D引擎了. 2016年9月7日,苹果发布iOS 10.2016年9月14日,全新的操 ...

  8. vscode教程(基础篇)

    转载:https://segmentfault.com/a/1190000017949680 本文主要介绍vscode在工作中常用的快捷键及插件,目标在于提高工作效率 本文的快捷键是基于mac的,wi ...

  9. CentOS7安装CDH 第十四章:CDH的优化

    相关文章链接 CentOS7安装CDH 第一章:CentOS7系统安装 CentOS7安装CDH 第二章:CentOS7各个软件安装和启动 CentOS7安装CDH 第三章:CDH中的问题和解决方法 ...

  10. C#-FileHelper

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...