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服务器安装oracle

    Linux安装Oracle 11g服务器(图文) 应该是最完整的Oracle安装教程了,全程在测试服务器上完成,软件环境:Red Hat Enterprise Linux 6:Oracle 11g ( ...

  2. C#7 进入快速迭代道路

    out变量 有一定C#编程经历的园友一定没少写如下这样的代码: int speed; if (int.TryParse(speedStr, out speed)) speed*=; 注释:int.Tr ...

  3. Linux 服务器修改时间与时间同步

    设置时间 date --set '2015-11-23 0:10:40' # 方法一,通用 timedatectl set-time '2015-11-23 08:10:40' # 容器内可能不支持 ...

  4. windows下安装phpredis扩展

    根据phpyinfo获取自己的php信息 x86,php5.6,TS,VC11 在pecl网站上找到对应的版本 5.6 Thread Safe (TS) x86 https://pecl.php.ne ...

  5. 【转载】Sqlserver根据生日计算年龄

    在Sqlserver中,可以根据存储的出生年月字段计算出该用户的当前年龄信息,主要使用到DateDiff函数来实现.DateDiff函数的格式为DATEDIFF(datepart,startdate, ...

  6. How to : SAP PI Cache Refresh

    Requirement : Identify various tools/resources available to perform SAP PI Cache refresh . Please no ...

  7. 开发一个简单的工具,导出github仓库所有issue列表

    Jerry有一个github仓库,专门用来存放自己的知识管理,通过一条条的issue来记录具体的知识点: https://github.com/i042416/KnowlegeRepository/i ...

  8. gcc 编译的四大过程

    gcc 编译的四大过程(预处理-编译-汇编-链接 ) 我们来编译一个hello world 程序. #include <stdio.h> int main(int argc,const c ...

  9. 【前端适配】vw单位移动端适配方案

    近些年移动端的强势崛起,导致移动端适配越来越重要,个人之前一直使用的是rem进行适配,但是发现并不是非常完美,给力的是大漠老师写了一篇<如何在Vue项目中使用vw实现移动端适配>,比较完美 ...

  10. laravel withCount 统计关联数量

    roleModel定义关联 hasmany  public function users(){ return $this->hasMany('App\Models\Users', 'role_i ...