Good Bye 2018题解
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题解的更多相关文章
- Codeforces:Good Bye 2018(题解)
Good Bye 2018! 题目链接:https://codeforces.com/contest/1091 A. New Year and the Christmas Ornament 题意: 给 ...
- Good Bye 2018 (A~F, H)
目录 Codeforces 1091 A.New Year and the Christmas Ornament B.New Year and the Treasure Geolocation C.N ...
- WC 2018 题解
WC 2018 题解 一些感受.jpg 题目难度相较前些年会相对简单一点?(FAKE.jpg 平均码量符合WC风格?(甚至更多一点 出题人良心! [WC2018] 通道 一个不知道对不对的$\log ...
- Good Bye 2018
Good Bye 2018 2018年最后一场CF,OVER! 弱弱的我只能做出3道A,B,D~~~~ 最后几分钟,感觉找到了C题的规律,结束的那一刻,提交了一发 "Wrong answer ...
- Codeforces Good Bye 2018
咕bye 2018,因为我这场又咕咕咕了 无谓地感慨一句:时间过得真快啊(有毒 A.New Year and the Christmas Ornament 分类讨论后等差数列求和 又在凑字数了 #in ...
- PKUSC 2018 题解
PKUSC 2018 题解 Day 1 T1 真实排名 Link Solution 考虑对于每一个人单独算 每一个人有两种情况,翻倍和不翻倍,他的名次不变等价于大于等于他的人数不变 设当前考虑的人的成 ...
- Codeforces Good Bye 2016 题解
好久没有fst题了...比赛先A了前4题然后发现room里有人已经X完题了没办法只能去打E题,结果差一点点打完...然后C题fst掉了结果就掉rating 了...下面放题解 ### [A. New ...
- 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 的 ...
- 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 ...
随机推荐
- SQLSERVER远程链接Oracle数据库
原文地址: http://blog.sina.com.cn/s/blog_45eaa01a0102ywuk.html 使用SQL链接服务器远程访问Oracle数据库 在本机上通过SQL数据库的链接 ...
- Angular Material 学习笔记 Chips
依据 material guidelines, chips 可以用来做 filter https://material.io/design/components/chips.html#filter-c ...
- 2..net core 和.net framework 版本
同一台机器上可以安装多个版本的.net core runtime.比如: 每个.net core项目都可以指定自己所用的版本,所以改变某个项目的target version不会影响到其他的.安装新的r ...
- sql For xml path('') 备忘
sql 合并行使用的两个函数记录: SELECT CityName,STUFF((SELECT ',' + UserName FROM table1 subTitle WHERE CityName=A ...
- copy 合并
copy /b xxx.jpg + yyy.txt zzz.jpg /b 二进制 /a 文本
- springboot_2
1. 配置文件简介 spring boot使用一个全局配置文件:application.properties或者application.yml,放置在src/main/resources目录下或者类路 ...
- Python-pptx库的运用
Win32com该库需要调用Microsoft PowerPoint,我将重新安装计算机Win 10,简单安装了pycharm的最新版本,然后发现创建的项目与之前的创建的项目结构不同.还有更多这样的事 ...
- [原]Object-Oriented Programming With ANSI-C
前一段时间面试被问到一个问题,怎么用C去实现面向对象的特性,比如封装.继承和多态.我心想这不是闲的蛋疼么,好吧,我承认我不会...[大哭].然后去网上找相关的文章,有文章推荐了<Object-O ...
- synchronize与lock
1. synchronize的作用 synchronize是java最原始的同步关键字,通过对方法或者代码块进行加锁实现对临界区域的保护.线程每次进去同步方法或者代码块都需要申请锁,如果锁被占用则会等 ...
- 异常-Phoenix HBASE Last region should end with an empty key. You need to create a new region and regioninfo in HDFS to plug the hole
1 详细异常信息 RROR: There is a hole in the region chain between \x03\x00\x00\x00\x00\x00\x00\x00\x00 and ...