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. MFC入门(三)-- MFC图片/文字控件(循环显示文字和图片的小程序)

    惯例附上前几个博客的链接: MFC入门(一)简单配置:http://blog.csdn.net/zmdsjtu/article/details/52311107 MFC入门(二)读取输入字符:http ...

  2. Angularjs演示Service功能

    在angularjs中,我们可以自定义自己的service.可以说得是自定义的方法,函数. 下面我们一步一步来演示吧:首先为angularjs定义一个app: var demoApp = angula ...

  3. 转 edtools

     1.下载工具包:edtools.rar ,解压后放到磁盘的何意一个目录,如D:\edTools. 2.打开ED,打开“工具”-“配置用户工具”,在弹出的对象框中,在“组和工具项目”下拉框中选择一个工 ...

  4. Ionic App 启动时报Application Error - The connection to the server was unsuccessful

    最近在更新App的时候,发现在华为手机上报这个错误,有点困惑,查找资料分析,大概原因是程序在加载index.html网页时,加载的资源过多,造成时间超时, 这个时原因分析https://stackov ...

  5. Luogu P2261 [CQOI2007]余数求和

    最近中考放假几天都在怼一道BJOI2018的水题,但卡死在90pts跑不动啊! 然后今天发现终于过了然而Hack的数据全RE了然后就开始找新的题目来找回信心. 然后发现智能推荐里有这道题,然后想了1m ...

  6. [Socket]Socket文件传输

    1.Server import java.io.DataInputStream; import java.io.FileOutputStream; import java.io.IOException ...

  7. 【已解决】HeidiSQL连接(登录)MySQL数据库报错10061问题

    解决方法: 打开cmd->输入命令services.msc 然后打开即可解决.

  8. System.Data.SqlClient.SqlException:“对象名 'customer' 无效。"

    连接数据库出错, 错误原因:表名错误.

  9. vs感受,由于我的电脑装了俩年了!我直接写感受吧

    个人感受:最初的感觉,最开始装vs是因为我的电脑8.1不兼容vc6.0(一个挺坑的编程软件),最开始用vs的时候我还是一个小白什么都不懂,vs创建项目实在是太复杂,不看教程根本看不懂,也许是它能包容的 ...

  10. M2贡献分分配方案

    1.初始分每个人都为0. 2.每周分配任务,按任务计分. 3.每周每个人有12.5分. 4.次周完成本周任务计6分. 5.未全部完成本周任务计6分. 6.12月29日统计分数,多出来的分数按完成任务数 ...