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的更多相关文章

  1. 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) ...

  2. Codeforces Round #404 (Div. 2) DE

    昨晚玩游戏竟然不小心错过了CF..我是有多浪啊. 今天总算趁着下课时间补了,感觉最后两题还是挺有意思的,写个题解. D: 题目大意: 给出一个括号序列,问有多少个子序列 是k个'(' + k个')' ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. Codeforces Round #404 (Div. 2) A - Anton and Polyhedrons 水题

    A - Anton and Polyhedrons 题目连接: http://codeforces.com/contest/785/problem/A Description Anton's favo ...

  9. 【组合数】【乘法逆元】 Codeforces Round #404 (Div. 2) D. Anton and School - 2

    http://codeforces.com/blog/entry/50996 官方题解讲得很明白,在这里我复述一下. 枚举每个左括号,考虑计算一定包含其的简单括号序列的个数,只考虑其及其左侧的左括号, ...

随机推荐

  1. 10-51单片机ESP8266学习-AT指令(ESP8266连接路由器,建立TCP服务器,分别和C#TCP客户端和AndroidTCP客户端通信+花生壳远程通信)

    http://www.cnblogs.com/yangfengwu/p/8871464.html 先把源码和资料链接放到这里 源码链接:https://pan.baidu.com/s/1wT8KAOI ...

  2. c#中的多线程异常 (转载)

    1.对于Thread操作的异常处理 public static void Main() { try { Thread th = new Thread(DoWork); th.Start(); } ca ...

  3. React-Route的属性exact

    exact是Route下的一条属性,一般而言,react路由会匹配所有匹配到的路由组价,exact能够使得路由的匹配更严格一些. exact的值为bool型,为true是表示严格匹配,为false时为 ...

  4. spring boot 跨域请求

    场景 网站localhost:56338要访问网站localhost:3001的服务 在网站localhost:3001中增加CORS相关Java Config @Configuration @Ord ...

  5. Luogu P2002 消息扩散&&P1262 间谍网络

    怕自己太久没写Tarjan了就会把这种神仙算法忘掉. 其实这种类型的图论题的套路还是比较简单且显然的. P2002 消息扩散 很显然的题目,因为在一个环(其实就是强连通分量)中的城市都只需要让其中一个 ...

  6. 基于HTML5 Canvas的工控SCADA模拟飞机飞行

    昨天看到一篇文章说是学习如何开飞机的,然后我就想,如果我也可以开飞机那就好玩了,每个人小时候都想做飞行员!中国飞行员太难当了,再说也不轻易让你开飞机!后来我就想如果能用 HT 开飞机那就是真的有趣了, ...

  7. 一文让你完全弄懂Stegosaurus

    国内关于 Stegosaurus 的介绍少之又少,一般只是单纯的工具使用的讲解之类的,并且本人在学习过程中也是遇到了很多的问题,基于此种情况下写下此文,也是为我逝去的青春时光留个念想吧~ Stegos ...

  8. 理解Liang-Barsky裁剪算法的算法原理

    0.补充知识向量点积:结果等于0, 两向量垂直; 结果大于0, 两向量夹角小于90度; 结果小于0, 两向量夹角大于90度.直线的参数方程:(x1, y1)和(x2, y2)两点确定的直线, 其参数方 ...

  9. Linux 实验一 基础实践

    Linux 实践一 1:软件源的维护方法 删掉DEB打头的 在命令行中输入命令时,可以用命令补全的方法. 下载完成后,使用sudo dpkg-i skype.deb 来完成安装. 2:掌握Linux ...

  10. 《Linux内核设计与分析》第六周读书笔记——第三章

    <Linux内核设计与实现>第六周读书笔记——第三章 20135301张忻估算学习时间:共2.5小时读书:2.0代码:0作业:0博客:0.5实际学习时间:共3.0小时读书:2.0代码:0作 ...