A. Initial Bet

题意:给出5个数,判断它们的和是否为5的倍数,注意和为0的情况

 #include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<algorithm>
using namespace std; typedef long long LL; int main()
{
int i,x,sum=;
for(i=;i<=;i++){
cin>>x;
sum+=x;
}
if(sum%==&&sum!=) printf("%d\n",sum/);
else printf("-1\n");
return ;
}

补------------------------------------------

B. Random Teams

题意:给出n个人,需要分成m个组,称分到同一组里的任意两个人为一队 求最小的对数,最大的对数。

首先好考虑的是最大对数,让人尽量集中在一起, 即为前m-1组全为1个人,最后一组为n-(m-1)个人

然后是最小的对数,与最大相反,应该让人数尽量分散,即为先每一组分n/m个人,在将余数依次添加到n%m个组上

比如10个人,6组

yushu=10%6=4

ans=10/6=1

1 1 1 1 1 1

依次添加余数

2 2 2 2 1 1

即为有yushu个组是人数为ans+1,(m-yushu)个组是ans个人

 #include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<algorithm>
using namespace std; typedef long long LL; int main()
{
LL mx,mn=,m,n;
cin>>n>>m;
LL d=n%m;
LL ans=n/m;
mx=(n-(m-))*(n-(m-)-)/;
mn=(d*(ans+)*ans)/+(m-d)*ans*(ans-)/;
cout<<mn<<' '<<mx<<"\n";
return ;
}

C. Table Decorations

题意:给出三种颜色的气球个数a,b,c,一张桌子不能全是一种颜色的气球,问最多可以装饰多少个桌子

这道题目是看题解都看得好艰难= =

假设a<b<c,最多可以装饰ans张桌子

结论是:当c>=2*(a+b) ans=a+b

当c<2*(a+b)  ans=(a+b+c)/3

当c>=2*(a+b)的时候好证明:即为每次从c中取2,从(a,b)里面任选一个,因为c是大于等于2*(a+b)的,对于任意从(a,b)里面任意选出来的一个,都能从c里面取出2 即只需考虑a+b,所以为a+b

第二种情况= =还木有看懂

 #include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<algorithm>
using namespace std; typedef long long LL;
LL a[]; int main()
{
int ans=;
while(cin>>a[]>>a[]>>a[]){
sort(a+,a++);
if(a[]>=*(a[]+a[])) cout<<a[]+a[]<<endl;
else cout<<(a[]+a[]+a[])/<<endl;
}
return ;
}

D是dp= =

Codeforces Round #273 (Div. 2)的更多相关文章

  1. 贪心 Codeforces Round #273 (Div. 2) C. Table Decorations

    题目传送门 /* 贪心:排序后,当a[3] > 2 * (a[1] + a[2]), 可以最多的2个,其他的都是1个,ggr,ggb, ggr... ans = a[1] + a[2]; 或先2 ...

  2. Codeforces Round #273 (Div. 2)-C. Table Decorations

    http://codeforces.com/contest/478/problem/C C. Table Decorations time limit per test 1 second memory ...

  3. Codeforces Round #273 (Div. 2)-B. Random Teams

    http://codeforces.com/contest/478/problem/B B. Random Teams time limit per test 1 second memory limi ...

  4. Codeforces Round #273 (Div. 2)-A. Initial Bet

    http://codeforces.com/contest/478/problem/A A. Initial Bet time limit per test 1 second memory limit ...

  5. Codeforces Round #273 (Div. 2) D. Red-Green Towers 背包dp

    D. Red-Green Towers time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  6. Codeforces Round #273 (Div. 2) A , B , C 水,数学,贪心

    A. Initial Bet time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  7. codeforces Codeforces Round #273 (Div. 2) 478B

    B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  8. codeforces 的 Codeforces Round #273 (Div. 2) --C Table Decorations

    C. Table Decorations time limit per test 1 second memory limit per test 256 megabytes input standard ...

  9. Codeforces Round #273 (Div. 2)D. Red-Green Towers DP

    D. Red-Green Towers   There are r red and g green blocks for construction of the red-green tower. Re ...

随机推荐

  1. Snapchat

    "Mesaging service Snapchat reportedly turned down a $3 billion offer from Facebook?!" Ever ...

  2. Educational Codeforces Round 11 C. Hard Process 前缀和+二分

    题目链接: http://codeforces.com/contest/660/problem/C 题意: 将最多k个0变成1,使得连续的1的个数最大 题解: 二分连续的1的个数x.用前缀和判断区间[ ...

  3. C# 获取属性字段上DescriptionAttribute的值

    var ent = new Ent(); foreach (var item in ent.GetType().GetProperties()) { var v = (DescriptionAttri ...

  4. spoj 1108

    要求输出一个牌的顺序 使每隔1.2.......n翻牌后出现1 2 3 4 5 6 7 8 9 .... n 将牌想象成n个空格  正向推 空n个位置放n 循环 需优化 #include <io ...

  5. Unity3D角色攻击范围判定和攻击判定

    原地址:http://www.unity蛮牛.com/blog-1801-479.html 第一种方法:运用点乘 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 ...

  6. Appium —— desired_capabilities详解

    Appium 服务关键字 关键字 描述 实例 automationName 你想使用的自动化测试引擎 Appium (默认) 或 Selendroid platformName 你要测试的手机操作系统 ...

  7. unity3d GameObject.Find 严格区分大小写的

    GameObject.Find 查找 static function Find (name : string) : GameObject Description描述 Finds a game obje ...

  8. java基础知识回顾之java Thread类学习(七)--java多线程安全问题(死锁)

    死锁:是两个或者两个以上的线程被无限的阻塞,线程之间互相等待所需资源. 线程死锁产生的条件: 当两个线程相互调用Join()方法. 当两个线程使用嵌套的同步代码块的时候,一个线程占用了另一个线程的锁, ...

  9. Bessie的体重问题

    P1028 Bessie的体重问题 时间: 1000ms / 空间: 131072KiB / Java类名: Main 背景 USACO OCT09 8TH  描述 Bessie像她的诸多姊妹一样,因 ...

  10. 欧拉工程第69题:Totient maximum

    题目链接 欧拉函数φ(n)(有时也叫做phi函数)可以用来计算小于n 的数字中与n互质的数字的个数. 当n小于1,000,000时候,n/φ(n)最大值时候的n. 欧拉函数维基百科链接 这里的是p是n ...