Good Bye 2018题解

题解 CF1091A 【New Year and the Christmas Ornament】

打完cf都忘记写题解了qwq

题意就是:给你一些黄,蓝,红的球,满足蓝的数量恰比黄的多一,红的数量恰比蓝的多一

容易发现黄的数量恰是\(\min{y,b-1,r-2}\)

输出这个值\(*3+3\)即可

# include <bits/stdc++.h>

int main()
{
int y, b, r;
scanf("%d%d%d", &y, &b, &r);
int ans = std::min(std::min(y, b - 1), r - 2);
printf("%d\n", ans * 3 + 3);
return 0;
}

题解 CF1091B 【New Year and the Treasure Geolocation】

打cf时网速感人qwq

容易想到一个\(O(n^3)\)的做法:枚举每一对\((x,y)\)与每一对\((a,b)\)配对,再判断是否满足条件,满足就输出

但是这样会超时,怎么办?

可以发现我们只要把每一个\((x,y)\)与第一个\((a,b)​\)配对即可

原因?因为每一对\((x,y)\)与每一对\((a,b)\)配对都要导致第一个\((a,b)\)与某一个\((x,y)\)配对,而任意一对这样的配对即可唯一确定\(T\)的位置,故只要枚举一遍每一个\((x,y)\)与第一个\((a,b)\)配对就能遍历所有情况。

时间复杂度\(O(n^2)\)

# include <bits/stdc++.h>
# define p std::pair<int, int> p pos[1010], change[1010]; std::map<p, int> m, tmp; int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
scanf("%d%d", &pos[i].first, &pos[i].second);
for(int i = 1; i <= n; i++)
scanf("%d%d", &change[i].first, &change[i].second), m[change[i]]++;
for(int i = 1; i <= n; i++)
{
p T;
T.first = pos[i].first + change[1].first;
T.second = pos[i].second + change[1].second;
tmp = m;
int flag = true;
for(int j = 1; j <= n; j++)
{
p tem;
tem.first = T.first - pos[j].first;
tem.second = T.second - pos[j].second;
if(!tmp[tem])
flag = false;
--tmp[tem];
}
if(flag)
return 0 * printf("%d %d\n", T.first, T.second);
}
return 0;
}

题解 CF1091C 【New Year and the Sphere Transmission】

这个C真烧脑qwq

可以发现每一次选的数的个数都是\(n\)的约数

枚举所有约数,计算答案即可(等差数列求和好评!)

#include <bits/stdc++.h>
#define ll long long
std::vector<ll> v, ans;
void prime(ll n)
{
for (int i = 1; i * i <= n; ++i)
{
if (n % i == 0)
{
v.push_back(i);
if (i * i != n)
{
v.push_back(n / i);
}
}
}
}
std::map<ll, int> m;
int main()
{
ll n;
scanf("%I64d", &n);
prime(n);
for (int i = 0; i < v.size(); i++)
{
m[v[i]] = 1;
}
for(std::map<ll, int>::iterator it = m.begin(); it != m.end(); it++)
{
ll x = n / it->first;
ans.push_back((1 + (x * (it->first - 1) + 1)) * (it->first) / 2);
}
std::sort(ans.begin(), ans.end());
for(int i = 0; i < ans.size(); i++)
printf("%I64d\n", ans[i]);
return 0;
}

Good Bye 2018题解的更多相关文章

  1. Codeforces:Good Bye 2018(题解)

    Good Bye 2018! 题目链接:https://codeforces.com/contest/1091 A. New Year and the Christmas Ornament 题意: 给 ...

  2. Good Bye 2018 (A~F, H)

    目录 Codeforces 1091 A.New Year and the Christmas Ornament B.New Year and the Treasure Geolocation C.N ...

  3. WC 2018 题解

    WC 2018 题解 一些感受.jpg 题目难度相较前些年会相对简单一点?(FAKE.jpg 平均码量符合WC风格?(甚至更多一点 出题人良心! [WC2018] 通道 一个不知道对不对的$\log ...

  4. Good Bye 2018

    Good Bye 2018 2018年最后一场CF,OVER! 弱弱的我只能做出3道A,B,D~~~~ 最后几分钟,感觉找到了C题的规律,结束的那一刻,提交了一发 "Wrong answer ...

  5. Codeforces Good Bye 2018

    咕bye 2018,因为我这场又咕咕咕了 无谓地感慨一句:时间过得真快啊(有毒 A.New Year and the Christmas Ornament 分类讨论后等差数列求和 又在凑字数了 #in ...

  6. PKUSC 2018 题解

    PKUSC 2018 题解 Day 1 T1 真实排名 Link Solution 考虑对于每一个人单独算 每一个人有两种情况,翻倍和不翻倍,他的名次不变等价于大于等于他的人数不变 设当前考虑的人的成 ...

  7. Codeforces Good Bye 2016 题解

    好久没有fst题了...比赛先A了前4题然后发现room里有人已经X完题了没办法只能去打E题,结果差一点点打完...然后C题fst掉了结果就掉rating 了...下面放题解 ### [A. New ...

  8. Good Bye 2018 D. New Year and the Permutation Concatenation

    传送门 https://www.cnblogs.com/violet-acmer/p/10201535.html 题意: 求 n 的所有全排列组成的序列中连续的 n 个数加和为 n*(n+1)/2 的 ...

  9. Good Bye 2018 C. New Year and the Sphere Transmission

    传送门 https://www.cnblogs.com/violet-acmer/p/10201535.html 题意: n 个people,编号1~n,按顺时针方向围城一圈: 初始,编号为1的peo ...

随机推荐

  1. fabric.js 知识点整理

    fabric.js是一个很好用的 canvas 操作插件,下面整理了一些平时项目中用到的知识点: //1: 获得画布上的所有对象: var items = canvas.getObjects(); / ...

  2. 设计模式--装饰者模式(io流中使用的模式)

    重点: 1.动态扩展对象,替换之前需要继承才能实现的功能. 2.具体工作的,仍然是被包装的对象,(有点锦上添花的意思,顾名思义仅仅起到装饰的作用,主体不变). 对比继承: 1.减少类的数量. 如果使用 ...

  3. 1.sql统计语句

    select exam_item_code, exam_item, EXAMDATE, count(distinct patient_id) from (select t2.exam_item_cod ...

  4. Spring Cloud Alibaba学习笔记(9) - RocketMQ安装与RocketMQ控制台

    搭建RocketMQ 系统环境准备 64位操作系统,推荐使用Linux.Unix.MacOS 64位 JDK1.8+ Maven 3.2.x 适用于Broker服务器的4g +可用磁盘 下载与搭建 下 ...

  5. springboot + shiro 构建权限模块

    权限模块基本流程 权限模块的基本流程:用户申请账号和权限 -->登陆认证 -->安全管控模块认证 -->调用具体权限模块(基于角色的权限控制) --> 登陆成功 -->访 ...

  6. webstorm处理代码冲突

     出现这个冲突界面后,不要关闭弹窗,不然会把冲突更新下来,也不要点merge. 正确做法:双击文件开始解决冲突!!!!

  7. kubernets 证书过期的问题

    .问题起源 kubeadm 是 kubernetes 提供的一个初始化集群的工具,使用起来非常方便.但是它创建的apiserver.controller-manager等证书默认只有一年的有效期,同时 ...

  8. element-ui 日期选择器范围时间限制

    来自 https://www.cnblogs.com/xjcjcsy/p/7977966.html 侵删 ElementUI是饿了么推出的一套基于vue2.x的一个ui框架.官方文档也很详细,这里做一 ...

  9. Python 使用gevent下载图片案例

    import urllib.request import gevent from gevent import monkey monkey.patch_all() def downloader(img_ ...

  10. stm32内联汇编

    首先,先看一下mdk下的混合编程的基本方法: 使用如上方法就可以进行混合编程了. 但是要特殊注意一点,个人感觉这个是直接调用一个代码段,并非一个函数,因为他不会保护调用这个代码段之前的现场.比如: 在 ...