题意:有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 (贪心)的更多相关文章

  1. UVALive - 4094 WonderTeam (贪心)

    题目大意: 有n支队伍,每两支队伍打两场比赛(主客场各一次),胜得3分,平得1分,输不得分,比赛结束之后会评选出一个梦之队,梦之队满足以下条件:进球总数最多,胜利场数最多,丢求总数最少,三个都不能并列 ...

  2. 【UVALive】4094 WonderTeam(神结论)

    题目 传送门:QWQ 分析 好神的结论啊 看代码吧(Length只有85) 代码 顺手压了压代码      目前代码长度rk1 vjudge #include <iostream> ?:n ...

  3. UVAlive 2911 Maximum(贪心)

    Let x1, x2,..., xm be real numbers satisfying the following conditions: a) -xi ; b) x1 + x2 +...+ xm ...

  4. uvalive 2911 Maximum(贪心)

    题目连接:2911 - Maximum 题目大意:给出m, p, a, b,然后xi满足题目中的两个公式, 要求求的 xp1 + xp2 +...+ xpm 的最大值. 解题思路:可以将x1 + x2 ...

  5. UVALive - 4225(贪心)

    题目链接:https://vjudge.net/contest/244167#problem/F 题目: Given any integer base b ≥ 2, it is well known ...

  6. UVALive 4850 Installations 贪心

    题目链接  题意 工程师要安装n个服务,其中服务Ji需要si单位的安装时间,截止时间为di.超时会有惩罚值,若实际完成时间为ci,则惩罚值为max{0,ci-di}.从0时刻开始执行任务,问惩罚值最大 ...

  7. UVALive 4863 Balloons 贪心/费用流

    There will be several test cases in the input. Each test case will begin with a line with three inte ...

  8. UVALive - 6268 Cycling 贪心

    UVALive - 6268 Cycling 题意:从一端走到另一端,有T个红绿灯,告诉你红绿灯的持续时间,求最短的到达终点的时间.x 思路:

  9. UVALive 4731 dp+贪心

    这个题首先要利用题目的特性,先贪心,否则无法进行DP 因为求期望的话,越后面的乘的越大,所以为了得到最小值,应该把概率值降序排序,把大的数跟小的系数相乘 然后这种dp的特性就是转移的时候,由 i推到i ...

随机推荐

  1. java中使用js函数

    JDK6已经发布很久了,很早就听过他已经支持脚本语言了,不过一直没有时间尝试,今天偷闲试了一下,感觉不错. javax.script包它是Java新增的操作脚本的工具包, 利用它我们可以对脚本语言进行 ...

  2. mongo 数据库提前关闭 避免读写任务没有结束,异步任务没有完成,同步指令提前关闭数据库:'MongoError: server instance pool was destroyed'

    mongo 数据库提前关闭 // mongodb - npm https://www.npmjs.com/package/mongodb const mongoCfg = { uri: 'mongod ...

  3. php总结8——mysql函数库、增删改

    8.1 mysql函数库 php的函数   .php中用来操作mysql函数库的函数 常用函数 mysql_connect("主机名称/ip","用户名",&q ...

  4. 怎样拆分View Controller进而实现轻量级的View Controller[UIKit]

    參考文章来自objcio站点   为什么要编写轻量级的View Controller??   1.作为iOS项目中最大的文件,ViewControllers中的代码复用率差点儿是最低的 2.重量级的V ...

  5. 阿里云ecs docker使用(2)

    1. 退出docker容器 命令 exit 2.sudo docker ps -l 3. sudo docker images 4. sudo docker commit ba300f05c1a3 c ...

  6. YTST_CX_0001(ALV栏位汇总)

    *********************************************************************** * Title           : X        ...

  7. 让我们再谈谈 iOS 安全

    前言 安全方面的话题总是聊不完的.这不,国外一家有名的专门攻击别人的安全公司 Hacking Team 自己被 Hack 了,结果有 400 多 G 的攻击资料泄漏出来,包括一些 0-day 的漏洞. ...

  8. css三角形实现的几种方法的区别

    演变: .triangle{ height: 30px; width: 30px; display: inline-block; border: 30px solid; border-color: # ...

  9. git常用开发流程

    我们在使用git进行项目管理时,远程仓库的分支情况一般是: master分支作为稳定版分支,用于直接发布产品,dev分支则用于日常开发 备注: 也可以只有一个master分支,这里只介绍第一种情况. ...

  10. js调试笔记

    js调试方法很多,今天总结一下最实用的的断点方法: debugger断点 这个很常见,但许多人不知道其实可以添加条件判断 if(something){debugger;} source断点 这个最为常 ...