UVaLive 4094 WonderTeam (贪心)
题意:有n支队伍,每两支队伍打两场比赛(主客场各一次),胜得3分,平得1分,输不得分,比赛结束之后会评选出一个梦之队,
梦之队满足以下条件:进球总数最多,胜利场数最多,丢求总数最少,三个都不能并列,求梦之队的最低排名
析:http://blog.csdn.net/l123012013048/article/details/44001543
1.让梦之队的胜利场的进球总数达到无穷大(当然这是不可能的),输的场都是进0球对方队伍进1球,平的场都是0:0的得分,
这样即使梦之队只赢一场也能达到进球总数最多了,其他队伍的平局的时候就让其丢求数大于梦之队的总丢球数,这样梦之队的丢球总数就是最少了
2.胜利场数最多,胜利场的得分是3分,要让梦之队的排名尽量低的话,胜利场数就不能太多,输的场数让其多一点
所以让梦之队只赢两场,其他队伍都赢1场,这样就能推出梦之队的排名了
队伍 赢 输 平 总分
梦之队 2 n-1 n-3 n+3
队伍1 1 1 2 n-4 2n-1
队伍2 1 1 2n-4 2n-1
其他队伍 1 0 2n-3 2n
由以上可以推出
n <= 3 时 梦之队第一名
n == 4 时 第二名
n > 4 时 最后一名
代码如下:
#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 debug() puts("++++");
#define gcd(a, b) __gcd(a, b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-5;
const int maxn = 1e6 + 10;
const int mod = 1e6 + 10;
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 bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} int main(){
while(cin >> n && n)
if(n < 4) cout << "1" << endl;
else if(4 == n) cout << "2" << endl;
else cout << n << endl;
return 0;
}
UVaLive 4094 WonderTeam (贪心)的更多相关文章
- UVALive - 4094 WonderTeam (贪心)
题目大意: 有n支队伍,每两支队伍打两场比赛(主客场各一次),胜得3分,平得1分,输不得分,比赛结束之后会评选出一个梦之队,梦之队满足以下条件:进球总数最多,胜利场数最多,丢求总数最少,三个都不能并列 ...
- 【UVALive】4094 WonderTeam(神结论)
题目 传送门:QWQ 分析 好神的结论啊 看代码吧(Length只有85) 代码 顺手压了压代码 目前代码长度rk1 vjudge #include <iostream> ?:n ...
- UVAlive 2911 Maximum(贪心)
Let x1, x2,..., xm be real numbers satisfying the following conditions: a) -xi ; b) x1 + x2 +...+ xm ...
- uvalive 2911 Maximum(贪心)
题目连接:2911 - Maximum 题目大意:给出m, p, a, b,然后xi满足题目中的两个公式, 要求求的 xp1 + xp2 +...+ xpm 的最大值. 解题思路:可以将x1 + x2 ...
- UVALive - 4225(贪心)
题目链接:https://vjudge.net/contest/244167#problem/F 题目: Given any integer base b ≥ 2, it is well known ...
- UVALive 4850 Installations 贪心
题目链接 题意 工程师要安装n个服务,其中服务Ji需要si单位的安装时间,截止时间为di.超时会有惩罚值,若实际完成时间为ci,则惩罚值为max{0,ci-di}.从0时刻开始执行任务,问惩罚值最大 ...
- UVALive 4863 Balloons 贪心/费用流
There will be several test cases in the input. Each test case will begin with a line with three inte ...
- UVALive - 6268 Cycling 贪心
UVALive - 6268 Cycling 题意:从一端走到另一端,有T个红绿灯,告诉你红绿灯的持续时间,求最短的到达终点的时间.x 思路:
- UVALive 4731 dp+贪心
这个题首先要利用题目的特性,先贪心,否则无法进行DP 因为求期望的话,越后面的乘的越大,所以为了得到最小值,应该把概率值降序排序,把大的数跟小的系数相乘 然后这种dp的特性就是转移的时候,由 i推到i ...
随机推荐
- 我的Java开发学习之旅------>Java经典排序算法之冒泡排序
冒泡排序(Bubble Sort)是一种简单的排序算法.它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来.走访数列的工作是重复地进行直到没有再需要交换,也就是说该数列已 ...
- PHP加Nginx实现动态裁剪图片方案
许久以前写过一篇也是关于高性能PHP图片动态裁剪方案的文章,那文章使用的是nginx Cache和rewrite实现的,当然再加上CDN,那个方案存在一个问题就是图片并没有实际生成,而是以二进制的形式 ...
- 微信小程序开发:学习笔记[7]——理解小程序的宿主环境
微信小程序开发:学习笔记[7]——理解小程序的宿主环境 渲染层与逻辑层 小程序的运行环境分成渲染层和逻辑层. 程序构造器
- A Pangram
Codeforces Round #295 div2 的A题,题意是判读一个字符串是不是全字母句,也就是这个字符串是否包含了26个字母,无论大小写. Sample test(s) input 12 t ...
- [egret+pomelo]实时游戏杂记(2)
[egret+pomelo]学习笔记(1) [egret+pomelo]学习笔记(2) [egret+pomelo]学习笔记(3) pomelo pomelo服务端介绍(game-server/con ...
- spring boot集成多数据源过程以及错误
https://blog.csdn.net/aa456aaxxx/article/details/80346703 出现BindingException错误 解决如下 https://my.osch ...
- 9.1 NOIP普及组试题精解(2)
9-4 soldier.c #include <stdio.h> #define MAXN 21 }; int n, m, x, y; //n,m为B点的行列坐标位置,x,y为马的坐标位置 ...
- 农业公司flash动画模板
农业公司flash动画素材下载模板是一款绿色水果蔬菜种植企业的flash动画模板. 下载:http://www.huiyi8.com/sc/10576.html
- 分享知识-快乐自己:intellij Idea报错Could not autowire. No beans of...
intellig idea 使用@Resource或者@Autowire报错,出现红色波浪线: 虽然不影响使用,但是看着很不爽,所以还是解决了下: 报错提示: Could not autowire. ...
- NOIP 2014【斗地主】
这真是道大火题. 因为保证数据随机,所以开始很多人直接用搜索 + 贪心水过去了,后来,为了遏制骗分这种不良风气的传播,各大 OJ 相继推出了斗地主加强版-- 正解: 先爆搜顺子,枚举打或不打,打多少张 ...