题意:有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. vscode webstrom 配置 eslint 使用 airbnb 规范

    1.安装eslint npm eslint-plugin-react eslint-plugin-import babel-eslint -g 2.全局配置文件,放到c:/user/***/ { &q ...

  2. 错误: 非法字符: '\ufeff' 解决方案|错误: 需要class, interface或enum

    解决方案,把文件用Editplus打开,UTF-8+BOM编码的文件转为普通的UTF-8文件

  3. IOS 获取 文件(UIImage) 创建时间

    Image 在手机里 如果是手机拍的那么能使用ALAssetsLibrary获取一系列 图片的信息 颜色.GPS.尺寸.创建日期等 使用ALAssetsLibrary导入框架AssetsLibrary ...

  4. 【Leetcode-easy】Reverse Integer

    思路:取绝对值,反转,并判断反转的结果是否大于最大整数,需要注意的细节:判断时需要这样:result > (Integer.MAX_VALUE - v) / 10 否则result * 10 + ...

  5. LightOJ - 1151 Snakes and Ladders —— 期望、高斯消元法

    题目链接:https://vjudge.net/problem/LightOJ-1151 1151 - Snakes and Ladders    PDF (English) Statistics F ...

  6. 一、为什么要学习Java虚拟机?

    一.为什么要学习Java虚拟机?       这里我们使用举例来说明为什么要学习Java虚拟机,其实这个问题就和为什么要学习数据结构和算法是一个道理,工欲善其事,必先利其器.曾经的我经常害怕处理内存溢 ...

  7. Zeppelin- Linux下安装Zeppelin

    前期部署: 下载,解压,配置PATH环境(编辑/etc/profile文件,记得source一下该文件) zepplin配置参考文档:https://zeppelin.apache.org/docs/ ...

  8. 【HDU2050】折线分割平面

    Position Solution 2×n^2-n+1 证明见分割问题 Code // This file is made by YJinpeng,created by XuYike's black ...

  9. hdu 1002 A + B Problem II(大数)

    题意:就是求a+b (a,b都不超过1000位) 思路:用数组存储 第一道大数的题目,虽然很水,纪念一下! 代码: #include<cstdio> #include<cstring ...

  10. openfire XML流

    XML流 概览 两个基本概念,XML流和XML节,使得在出席信息已知的实体之间,异步交换低负载的结构化信息成为可能.这两个术语定义如下: XML流的定义:一个XML流是一个容器,包含了两个实体之间通过 ...