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. python属性查找 深入理解(attribute lookup)

    在Python中,属性查找(attribute lookup)是比较复杂的,特别是涉及到描述符descriptor的时候. 在上一文章末尾,给出了一段代码,就涉及到descriptor与attribu ...

  2. Kubernetes-v1.12.0基于kubeadm部署

    1.主机规划 #master节点(etcd/apiserver/scheduler/controller manager)master.example.cometh0: 192.168.0.135et ...

  3. 将WinForm程序(含多个非托管Dll)合并成一个exe的方法

    原文:将WinForm程序(含多个非托管Dll)合并成一个exe的方法 开发程序的时候经常会引用一些第三方的DLL,然后编译生成的exe文件就不能脱离这些DLL独立运行了. ILMerge能把托管dl ...

  4. BootStrap学习(3)_导航菜单

    一.导航元素 1.表格导航或标签 以一个带有 class .nav 的无序列表开始. 添加 class .nav-tabs. <!DOCTYPE html> <html xmlns= ...

  5. Luogu P1439 【模板】最长公共子序列

    又是模板题呵,但这次的难度有点增加. 先看题目第一个想到DP的经典算法,要O(n^2),然后想其它的算法. 其实我们衢州市一次联考有一题很像这题,不过还要难一点. 思想是离散化+最长不下降子序列(在这 ...

  6. [Oracle]获得PDB相关的xml 文件

    问题:客户进行了PDB的克隆之后,发现启动时出现: ORA-44777: Pluggable database service cannot be started. 分析手段: 为了获得PDB的相关信 ...

  7. 总目录(Catalog)

    总目录(Catalog) C#高级编程(C# advanced programming) 1.并发编程(Concurrent programming)(8) ...... 数据结构与算法(Data s ...

  8. 并行编程(Parallel Framework)

    前言 并行编程:通过编码方式利用多核或多处理器称为并行编程,多线程概念的一个子集. 并行处理:把正在执行的大量的任务分割成小块,分配给多个同时运行的线程.多线程的一种. 并行编程分为如下几个结构: 1 ...

  9. vue开发小结(下)

    前言 继前几天总结了vue开发小结(上)后,发现还有很多的点没有能列举出来,于是还是打算新建一个下篇,再补充一些vue开发中需要注意的细节,确实还是都是细节的问题,我只是在这里强调下,希望对大家有帮助 ...

  10. 该如何以正确的姿势插入SVG Sprites?

    大家好,我是苏南,今天要给大家分享的是SVG sprite(也叫雪碧图),所谓雪碧图,当然就不是我们常喝的雪碧饮料(Sprites)哦,哈哈- 当下流程的移动端,手机型号太多太多,今天工作项目中突然发 ...