Codefroces #404 Div2
分析:把多面体和面数一一对应即可
#include<iostream>
#include<map>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
int T;
while(cin>>T){
map<string,int>mp;
mp["Tetrahedron"]=;
mp["Cube"]=;
mp["Octahedron"]=;
mp["Dodecahedron"]=;
mp["Icosahedron"]=;
long long sum=;
for(int i=;i<T;i++){
string s;
cin>>s;
sum+=mp[s];
}
cout<<sum<<endl;
}
return ;
}
分析:分别统计最早的r1和最晚的l2,以及最早的r2和最晚的l1,求二者的最大值即可
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=+;
const int INF=;
typedef struct
{
long long l,r;
}point;
point p1[maxn],p2[maxn];
bool cmp1(point a,point b){
return a.r<b.r;
}
bool cmp2(point a,point b){
return a.l>b.l;
}
int n,m;
int main()
{
while(cin>>n){
long long minx=INF;
for(int i=;i<n;i++){
scanf("%I64d%I64d",&p1[i].l,&p1[i].r);
}
sort(p1,p1+n,cmp1);
cin>>m;
for(int i=;i<m;i++){
scanf("%I64d%I64d",&p2[i].l,&p2[i].r);
}
sort(p2,p2+m,cmp2);
int i=,j=;
long long ans=;
long long cnt=p2[j].l-p1[i].r;
ans=max(ans,cnt);
sort(p1,p1+n,cmp2);
sort(p2,p2+m,cmp1);
long long h=;
h=max(h,(p1[j].l-p2[i].r));
ans=max(h,ans);
cout<<ans<<endl;
}
return ;
}
分析:若对于m>n,直接就是n天,若n>m,则前m天是必须的,后面相当于去寻找一个最小的x,使1+2+3+......+x>(n-m),所以二分答案即可
#include "iostream"
#include "cstdio"
#include "cstring"
using namespace std;
long long n,m;
int main()
{
while(cin>>n>>m){
if(m>n){
cout<<n<<endl;
continue;
}
n-=m;
long long l=,r=2e9;
while(l<r){
long long mid=(l+r)>>;
long long ans=(+mid)*mid/;
if(ans>=n) r=mid;
else l=mid+;
}
cout<<m+l<<endl;
}
return ;
}
Codefroces #404 Div2的更多相关文章
- Codefroces Round#427 div2
A. Key races time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Register-SPWorkflowService 404
最近需要做一个SharePoint 2013工作流演示环境. 于是在自己的本子上安装了一个虚拟机. 虚拟机操作系统是Windows Server 2012 R2,计划把AD.SQL Server 20 ...
- WinServer2008R2 + IIS 7.5 + .NET4.0 经典模式 运行WebAPI程序报404错误的解决方案
在Windows Server 2008 R2系统下,IIS 7.5 + .NET Framework 4.0的运行环境,以经典模式(Classic Mode)部署一个用.NET 4.0编译的 Web ...
- sqoop:Failed to download file from http://hdp01:8080/resources//oracle-jdbc-driver.jar due to HTTP error: HTTP Error 404: Not Found
环境:ambari2.3,centos7,sqoop1.4.6 问题描述:通过ambari安装了sqoop,又添加了oracle驱动配置,如下: 保存配置后,重启sqoop报错:http://hdp0 ...
- thinkphp访问不存在的模块或者方法跳转到404页面
使用的thinkphp 版本是3.2.0, 在config.php中配置 404地址,即可: 'TMPL_EXCEPTION_FILE' => './Application/Home/View/ ...
- 网站设置404页面 --nginx
有的时候根据域名要先知道用的什么web 服务器 最简单的 http://tool.chinaz.com/pagestatus/ 输入域名,看返回的头部信息 用的那个web浏览器 下面的方法也是根据头 ...
- HTTP 错误 404.3 – Not Found 由于扩展配置问题而无法提供您请求的页面。如果该页面是脚本,请添加处理程序。如果应下载文件,请添加 MIME 映射。
今天,在vs2013中新建了一个placard.json文件,当我用jq读取它的时候,去提示404,直接在浏览器访问这个文件,提示: HTTP 错误 404.3 – Not Found 由于扩展配置问 ...
- Windows Server 2008 R2 IIS7.5 部署 MVC HTTP 404.0 Not Found 错误
如图 在Windows Server 2008 R2 IIS7.5 部署 MVC HTTP 404.0 Not Found 错误,在Win7环境下测试正常,在百度中查找相关解决方法,如修改配置文件等, ...
- ajax 后台正常执行 错误类型却是404
后台执行importExcel,明明方法执行成功,但是前台却提示404 @RequestMapping("/import") public Json importExcel(@Re ...
随机推荐
- eopkg命令
#命令: add-repo (ar) ---添加存储库 blame (bl) ---包所有者和发布信息 build (bi) ---建立eopkg包 check ---验证安装 clean ...
- Unity 3D 之通过序列化来存档游戏数据
我们在使用u3d开发一些单机游戏的过程中,都会涉及到游戏数据的存单和加载.一般情况下,如果存储的数据不复杂,我们就可以用PlayerPrefs,但有时涉及到的数据更加复杂,使用PlayerPrefs难 ...
- STM32 GPIO寄存器 IDR ODR BSRR BRR
IDR是查看引脚电平状态用的寄存器,ODR是引脚电平输出的寄存器 下面内容的原文:http://m646208823.blog.163.com/blog/static/1669029532012931 ...
- delphi 与 sqlite3
delphi与sqlite file:0 前言 本文的目的在于采用流水账方式来记录学习delphi访问嵌入式数据库sqlite中的一些点滴.欢迎各位同好共同学习和批评指正. file:1 准备工作 ...
- Obj-C, library with ARC code and warning - Method possibly missing a [super dealloc] call?
1 down vote favorite I'm adding the MKStoreKit to my app and I'm getting a warning, Method possibly ...
- ios下读取jason中的nsstring时间并本地化成中文gmt时间显示上午下午
https://developer.apple.com/library/ios/qa/qa1480/_index.html - (NSDate *)dateFromString:(NSString * ...
- openURL
在iOS开发中,经常需要调用其它App,如拨打电话.发送邮件等.UIApplication:openURL:方法是实现这一目的的 在iOS开发中,经常需要调用其它App,如拨打电话.发送邮件等.UIA ...
- BUPT复试专题—数据库检索(2014软院)
题目描述 在数据库的操作过程中,我们进场会遇到检索操作.这个题目的任务是完成一些特定格式的检索,并输出符合条件的数据库中的所有结果. 我们现在有一个数据库,维护了学生的姓名(Name),性别(Sex) ...
- BUPT复试专题—众数(2014)
题目描述 有一个长度为N的非降数列,求数列中出现最多的数,若答案不唯一输出最小的数 输入 第一行T表示测试数据的组数(T<100) 对于每组测试数据: 第一行是一个正整数N表示数列长度 第二行有 ...
- vim修改二进制文件
先用vim以二进制格式打开需要编辑或查看的文件,不采用-b参数有时会导致转换错误,详见分隔线后部分. vim -b file-to-open.dat 然后用xxd把文件转换成十六进制格式 :%! ...