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. SkylineGlobe 如何实现工程进度管理或者说是对象生命周期管理

    SkylineGlobe 的 TerraExplorer Pro里面,给我们提供了一个Timespan Tags工具,通过这个工具,我们可以设置ProjectTree任务组对象的生命周期: 然后通过调 ...

  2. Lua 中的条件表达式

    下面这代码段看上去很熟悉,就是C#里面的条件表达式,很多其它语言也都有这么一个条件表达式. ; ; string c = "c"; string d = "d" ...

  3. xshell替代工具finalShell

    主要特性:1.多平台支持Windows,Mac OS X,Linux2.多标签,批量服务器管理.3.支持登录Ssh和Windows远程桌面.4.漂亮的平滑字体显示,内置100多个配色方案.5.终端,s ...

  4. [Oracle]TM lock (DML enqueue) 的相容性

    [Oracle]TM lock (DML enqueue) 的相容性 RS(SS):  行共享     LMODE =2 RX(SX):  行独占     LMODE =3 S:       共享   ...

  5. retinex图像增强算法的研究

    图像增强方面我共研究了Retinex.暗通道去雾.ACE等算法.其实,它们都是共通的.甚至可以说,Retinex和暗通道去雾就是同一个算法的两个不同视角,而ACE算法又是将Retinex和灰度世界等白 ...

  6. springmvc 解决 controller 中出现死循环并 stackoverflow 的问题

    这是因为这个controller中的方法返回值为void类型,且没有request response这类衍生的重定向,或者返回值为String,但是是null等等的情况,都会引起死循环,然后stack ...

  7. 仓储层接口IBaseRepository解析

    //代码调用由业务层调用,调用方式详见源代码的业务层,升级直接替换TT模板即可,无需覆盖系统using System; using System.Collections.Generic; using ...

  8. 基于Python的ModbusTCP客户端实现

    Modbus协议是由Modicon公司(现在的施耐德电气Schneider Electric)推出,主要建立在物理串口.以太网TCP/IP层之上,目前已经成为工业领域通信协议的业界标准,广泛应用在工业 ...

  9. C_数据结构_循环实现求阶乘

    # include <stdio.h> int main(void) { int val; printf("请输入一个数字:"); printf("val = ...

  10. 11.18 Daily Scrum

    这两天开发人员陆续提交了自己开发的部分. 目前所有开发任务都已经完成,剩下的只是测试和整合,做最后的冲刺. 明天的任务: 李承晗:测试与整合