Codeforces Round #404 (Div. 2)A,B,C
A. Anton and Polyhedrons
题目链接:http://codeforces.com/contest/785/problem/A
智障水题
实现代码:
#include<bits/stdc++.h>
using namespace std; int main(){
string s;
int ans=,t;
cin>>t;
while(t--){
cin>>s;
if(s=="Tetrahedron")
ans+=;
else if(s=="Cube")
ans+=;
else if(s=="Octahedron")
ans+=;
else if(s=="Dodecahedron")
ans+=;
else ans+=;
}
cout<<ans<<endl;
}
B. Anton and Classes
链接:http://codeforces.com/contest/785/problem/B
思路:想要最大的距离两种情况:
1.a数组在前,b在后,此时最大长度为b最大的左边界-a最小的右边界.
2.b数组在前,a在后,此时最大长度为a最大的左边界-b最小的右边界.
将这四个边界标记出来,讨论下两种情况就行了。
实现代码:
#include<bits/stdc++.h>
using namespace std;
#define Max 200009
const int inf = 2e9;
struct node{
int x,y;
};
int main()
{
int m,i,n,maxx=-inf,maxy=-inf,minx=inf,miny=inf;
node a,b;
cin>>m;
for(i=;i<=m;i++){
cin>>a.x>>a.y;
if(a.y<miny)
miny = a.y;
if(a.x>maxx)
maxx = a.x;}
cin>>n;
for(i=;i<=n;i++){
cin>>b.x>>b.y;
if(b.y<minx)
minx = b.y;
if(b.x>maxy)
maxy = b.x;
}
int ans = max(maxy-miny,maxx-minx);
if(ans<)
cout<<""<<endl;
else
cout<<ans<<endl;
}
C. Anton and Fairy Tale
链接:http://codeforces.com/contest/785/problem/C
解题思路:
一个房里有m粒米,每天补充n粒,每天损失天数粒米,第m天损失m粒米,如果没有米了直接结束,
有个特殊判断:当n>=m时,每天都能补满,只能等第m天一次损失完结束。
按题意可以推出当n天后每天损失n+i粒米,每天补充n粒米,也就是n天后每天损失i粒米。一开始的思路是直接将判断当m>=i*(i+1)/2,后面想到i额外损失的,实际上每天损失的米是n+i粒,在最后一天判断的时候会出错,因为他是先损失再补充如果一次直接损失完了,那么就直接结束了,所以正确的判断公式应该是(m-n)>=i*(i+1)/2
直接用二分爆搜就可以了,需要注意的是右边界可以选择10的十次方,如果是10的9次方搜不到1的18次方的数据,10的11次方又会爆掉。
实现代码:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll fun(ll x){
return (x+)*x/;
}
int main()
{
ll m,n,mid;
cin>>m>>n;
ll l = ,r = 1e10+;
ll ans = m-n;
if(n>=m){
cout<<m<<endl;
return ;
}
while(l<r){
mid = (l+r)/;
if(fun(mid)<ans)
l = mid;
else if(fun(mid)==ans){
cout<<n+mid<<endl;
return ;}
else if(fun(mid)>ans&&fun(mid-)<ans){
cout<<n+mid<<endl;
return ;}
else
r = mid;
}
return ;
}
Codeforces Round #404 (Div. 2)A,B,C的更多相关文章
- Codeforces Round #404 (Div. 2) C 二分查找
Codeforces Round #404 (Div. 2) 题意:对于 n and m (1 ≤ n, m ≤ 10^18) 找到 1) [n<= m] cout<<n; 2) ...
- Codeforces Round #404 (Div. 2) DE
昨晚玩游戏竟然不小心错过了CF..我是有多浪啊. 今天总算趁着下课时间补了,感觉最后两题还是挺有意思的,写个题解. D: 题目大意: 给出一个括号序列,问有多少个子序列 是k个'(' + k个')' ...
- Codeforces Round #404 (Div. 2) D. Anton and School - 2 数学
D. Anton and School - 2 题目连接: http://codeforces.com/contest/785/problem/D Description As you probabl ...
- Codeforces Round #404 (Div. 2) A,B,C,D,E 暴力,暴力,二分,范德蒙恒等式,树状数组+分块
题目链接:http://codeforces.com/contest/785 A. Anton and Polyhedrons time limit per test 2 seconds memory ...
- Codeforces Round #404 (Div. 2)(A.水,暴力,B,排序,贪心)
A. Anton and Polyhedrons time limit per test:2 seconds memory limit per test:256 megabytes input:sta ...
- Codeforces Round #404 (Div. 2) C. Anton and Fairy Tale 二分
C. Anton and Fairy Tale 题目连接: http://codeforces.com/contest/785/problem/C Description Anton likes to ...
- Codeforces Round #404 (Div. 2) B. Anton and Classes 水题
B. Anton and Classes 题目连接: http://codeforces.com/contest/785/problem/B Description Anton likes to pl ...
- Codeforces Round #404 (Div. 2) A - Anton and Polyhedrons 水题
A - Anton and Polyhedrons 题目连接: http://codeforces.com/contest/785/problem/A Description Anton's favo ...
- 【组合数】【乘法逆元】 Codeforces Round #404 (Div. 2) D. Anton and School - 2
http://codeforces.com/blog/entry/50996 官方题解讲得很明白,在这里我复述一下. 枚举每个左括号,考虑计算一定包含其的简单括号序列的个数,只考虑其及其左侧的左括号, ...
随机推荐
- IntelliJ IDEA 常用设置 (二)
一. 代码提示和补充功能有一个特性:区分大小写. 区分大小写的情况是这样的:比如我们在 Java 代码文件中输入 stringBuffer IntelliJ IDEA 是不会帮我们提示或是代码补充的, ...
- 从0移植uboot (一) _配置分析
来源:Linux社区 作者:xiaojiang1025 :http://www.linuxidc.com/Linux/2017-02/141018.htm 和绝大多数源码编译安装一样,uboot的 ...
- 05-Mirrorgate数据库信息
1.登录数据库 [root@node1 ~]# mongo localhost: > show dbs; admin .000GB dashboarddb .001GB local .000GB ...
- chrome浏览器直接打印 - z
在地址栏敲: about:flags ,打开设置界面:停用:Enable Print Preview Registration PromosChrome快捷方式增加:--kiosk-printing这 ...
- electron 开发实时加载
第一个方式 cnpm install electron-reload --save-dev cnpm install electron-prebuilt --save-dev require('ele ...
- 【SDOI2017】数字表格
题面 题解 这道题目还有一种比较有意思的解法. 定义一种运算\((\mathbf f\oplus\mathbf g)(x) = \prod\limits_{d\mid x}\mathbf f(d)^{ ...
- python中使用pymongo操作mongo
MongoDB是由C++语言编写的非关系型数据库,是一个基于分布式文件存储的开源数据库系统,其内容存储形式类似JSON对象,它的字段值可以包含其他文档.数组及文档数组,非常灵活.在这一节中,我们就来看 ...
- pycharm2019注册码一键实时获取,永久有效!
pycharm2019专业版激活码 56ZS5PQ1RF-eyJsaWNlbnNlSWQiOiI1NlpTNVBRMVJGIiwibGljZW5zZWVOYW1lIjoi5q2j54mI5o6I5p2 ...
- 【nodejs】让nodejs像后端mvc框架(asp.net mvc)一样处理请求--目录(8/8 完结)
为什么要做这个 在使用nodejs开发过程中,总是发现需要做很多重复性的体力劳动,且因为自身是服务端程序员出身,感觉有一些服务端好的东西其实可以在nodejs上得到应用并能提高一些开发工作效率. 本系 ...
- 移动端触摸(touch)事件
移动端时代已经到来,作为前端开发的我们没有理由也不应该坐井观天,而是勇敢地跳出心里的那口井,去拥抱蔚蓝的天空.该来的总会来,我们要做的就是接受未知的挑战.正如你所看到的,这是一篇关于移动端触摸事件的文 ...