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. html+css学习笔记 5[表格、表单]

    表格 -- 默认样式重置 表格标签:     table 表格     thead 表格头     tbody 表格主体     tfoot 表格尾     tr 表格行     th 元素定义表头 ...

  2. MVC3中在同一解决方案的不同项目中实现Area功能

    1.背景      微软在MVC中引入了Area概念,用于复杂项目的分工开发.如一个MVC项目中Controller过多时,就会导致项目中包含大量的Controller+View+Model,无论是查 ...

  3. Unity3D Development模式下的一个小问题

    今天客户提交了一个反馈,说测试版本的应用在按下电源键的时候屏幕变黑,然后重新按下电源键启动的时候发现没有出现屏幕锁屏的情况,直接回到应用界面. 我这边看了一下,发现如果装了360之类的手机助手就没这个 ...

  4. How to Enable 64-bit Processes for Enhanced Protected Mode in Internet Explorer 11 (IE11)

       Information Enhanced Protected Mode (EPM) adds additional security to Protected Mode and includes ...

  5. HDU 3038 How Many Answers Are Wrong(带权并查集)

    太坑人了啊,读入数据a,b,s的时候,我刚开始s用的%lld,给我WA. 实在找不到错误啊,后来不知怎么地突然有个想法,改成%I64d,竟然AC了 思路:我建立一个sum数组,设i的父亲为fa,sum ...

  6. IOS:利用dispatch_once创建单例

    在之前有一篇学习笔记中,记载了一篇如何在OC中实现单例的文章:<IOS学习笔记4—Objective C—创建单例>自苹果引入了Grand Central Dispatch (GCD)(M ...

  7. hdu 4187 Alphabet Soup

    这题的主要就是找循环节数,这里用找字符串最小覆盖来实现,也就是n-next[n],证明在这http://blog.csdn.net/fjsd155/article/details/6866991 #i ...

  8. CHM类型API文件打不开问题解决方法

    这是CHM文档被锁定导致的问题,选择CHM文件,右键属性,解除锁定

  9. hdu1102

    http://acm.hdu.edu.cn/showproblem.php?pid=1102 最小生成树(模板题) 3 0 990 692 990 0 179 692 179 0 1 1 2 一共3个 ...

  10. floodlight make the VMs can not getDHCP IP address

    https://answers.launchpad.net/neutron/+question/242170 这个问题我也遇到了,但是没人回答. floodlight make the VMs can ...