CodeForces 732C Sanatorium (if-else)
题意:某人去旅游,记录了一共吃了多少顿饭,早中晚,但是有可能缺少,问你最少缺少了多少顿。
析:每把三个数排序,然后再一一对比,肯定是以最大数为主,其他两个肯定是缺少了。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 500 + 5;
const int mod = 1e9 + 7;
const int dr[] = {-1, 1, 0, 0};
const int dc[] = {0, 0, 1, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} int main(){
LL a, b, c;
while(cin >> a >> b >> c){
LL ans;
if(a < b) swap(a, b);
if(a < c) swap(a, c);
if(b < c) swap(b, c);
if(a > b) ans = a - b + a - c - 2;
else if(a == b && b > c) ans = a - c - 1;
else ans = 0;
cout << ans << endl;
}
return 0;
}
CodeForces 732C Sanatorium (if-else)的更多相关文章
- CodeForces 732C Sanatorium
C. Sanatorium time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 【43.26%】【codeforces 732C】Sanatorium
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Codeforces Round #377 (Div. 2)A,B,C,D【二分】
PS:这一场真的是上分场,只要手速快就行.然而在自己做的时候不用翻译软件,看题非常吃力非常慢,还有给队友讲D题如何判断的时候又犯了一个毛病,一定要心平气和,比赛也要保证,不要用翻译软件做题: Code ...
- codeforces732C
Sanatorium CodeForces - 732C Vasiliy spent his vacation in a sanatorium, came back and found that he ...
- Codeforces Round #377 (Div. 2) C. Sanatorium 水题
C. Sanatorium time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
随机推荐
- poj3468,poj2528
其实这两题都是基础的线段树,但对于我这个线段树的初学者来说,总结一下还是很有用的: poj3468显然是线段树区间求和,区间更改的问题,而poj2528是对区间染色,问有多少种颜色的问题: 线段树的建 ...
- Tomcat 映射虚拟目录
设置虚拟目录映射一般有两种用途: (1)把整个web应用映射到tomcat中: 如一个testapp的web应用的路径是/opt/testapp,则通过虚拟目录映射可以将其映射到tomcat(weba ...
- HDU 3746 Cyclic Nacklace 环形项链(KMP,循环节)
题意: 给一个字符串,问:要补多少个字符才能让其出现循环?出现循环是指循环节与字符串长度不相等.比如abc要补多个变成abcabc.若已经循环,输出0. 思路: 根据最小循环节的公式,当len%(le ...
- 【C#学习笔记】载入图片并居中
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- 在linux下实现用ffmpeg把YUV420帧保存成图片
在网上搜了很久相关的问题,但是好像没有一个在linux下跑得比较完整的例子,不过经过自己一番搜索和总结,终于做出来了,哈哈,看下面的代码吧. 这个例子可以保存成bmp或者jpeg格式的图片. 下面的结 ...
- Android下高斯模糊的算法和demo
采用纯java和RenderScript两种方式来做高斯算法. 也可以用NDK来做,想试试的可以参考: http://stackoverflow.com/questions/2067955/fast- ...
- IIS部署网站
- NPlot开源画图类
一.net下的图表控件NPlot的基本用法 NPlot的基本用法 图表控件一直是很难找的,特别是免费又强大的.NPlot是一款非常难得的.Net平台下的图表控件,能做各种曲线图,柱状图,饼图,散 ...
- 动态 SQL
MyBatis 的强大特性之一便是它的动态 SQL.如果你有使用 JDBC 或其他类似框架的经验,你就能体会到根据不同条件拼接 SQL 语句有多么痛苦.拼接的时候要确保不能忘了必要的空格,还要注意省掉 ...
- 翻译【ElasticSearch Server】第一章:开始使用ElasticSearch集群(1)
我们要做的第一件事是安装ElasticSearch.对于多数应用程序,您开始安装和配置,通常忘记这些步骤的重要性,直到发生了糟糕的事情.这章我们将广泛关注ElasticSearch的这部分.请注意本章 ...