Codeforces Round #377 (Div. 2) C 模拟
来源:互联网 发布:c语言在线编程软件 编辑:程序博客网 时间:2024/05/16 04:45
题目传送门:http://codeforces.com/problemset/problem/732/C
题意:vasiliy去疗养院度假,他可能在早饭前,午饭前,晚饭前到,可能在早饭前,午饭前,晚饭前走。他有一张卡片上面记录了他在疗养院吃早饭,午饭,晚饭的次数,问他最少少吃了多少此饭
思路:由于他来跟离开的时间不确定,所以这三餐的数量可以不相等,但人依赖两个间的数量相差不会超过1,然后就能算了
代码如下:
#include <iostream>#include <algorithm>#include <cstring>#include <stdio.h>#include <string>#include <cmath>#include <queue>#include <set>#include <map>#include <stack>#include <bitset>#include <cstdlib>using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define ll long long#define ull unsigned long long#define mem(n,v) memset(n,v,sizeof(n))#define MAX 100005#define MAXN 10005#define PI 3.1415926#define E 2.718281828459#define opnin freopen("text.in.txt","r",stdin)#define opnout freopen("text.out.txt","w",stdout)#define clsin fclose(stdin)#define clsout fclose(stdout)#define haha1 cout << "haha1"<< endl#define haha2 cout << "haha2"<< endl#define haha3 cout << "haha3"<< endlconst int INF = 0x3f3f3f3f;const ll INFF = 0x3f3f3f3f3f3f3f3f;const double pi = 3.141592653589793;const double inf = 1e18;const double eps = 1e-8;const ll mod = 1e18;const ull mx = 133333331;/**************************************************************************/int main(){ ll a[3]; cin >> a[0] >> a[1] >> a[2]; sort(a,a+3); ll sum = 0; if(a[2] > a[1] + 1) sum += a[2] - 1 - a[1]; if(a[2] > a[0] + 1) sum += a[2] - 1 - a[0]; cout << sum << endl; return 0;}
0 0
- Codeforces Round #377 (Div. 2) C 模拟
- Codeforces Round #346 (Div. 2) C模拟
- Codeforces Round #325 (Div. 2) C 模拟
- Codeforces Round #316 (Div. 2) C 模拟
- Codeforces Round #306 (Div. 2) C 模拟
- Codeforces Round #126 (Div. 2) C 模拟
- Codeforces Round #373 (Div. 2) C 模拟
- Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2) C 模拟
- Codeforces Round #138 (Div. 2) c 数据结构模拟
- Codeforces Round #306 (Div. 2)C. Divisibility by Eight--模拟
- Codeforces Round #283 (Div. 2) C. Removing Columns 模拟+构造
- Codeforces Round #200 (Div. 2)344C Rational Resistance(模拟)
- C. Replacement( Codeforces Round #316 (Div. 2) 模拟)
- Codeforces Round #316 (Div. 2) C. Replacement (模拟)
- Codeforces Round #249 (Div. 2)453C Cardiogram(模拟)
- Codeforces Round #340 (Div. 2)(C)贪心,模拟
- Codeforces Round #321 (Div. 2)(C)模拟,DFS
- Codeforces Round #303 (Div. 2)-C. Woodcutters(模拟)
- Java设计模式学习03——建造者模式
- SSM实现最简单的登录验证
- iOS 修改UITextField 的placeholder字体大小和颜色
- Unity Shader基础(1)
- JAVA学习笔记001
- Codeforces Round #377 (Div. 2) C 模拟
- 点击GridView空白区域的事件处理
- python中 strip()方法
- jni之:eclipse上添加javah快捷菜单
- 网络配置记录
- 如何防止CSRF
- 1021. 个位数统计 (15)
- 快速集成 iMessage(下)
- 托福字典:progressively托福考试详解