Codeforces Round #273 (Div. 2)
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)的更多相关文章
- 贪心 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- ADT eclipse打开时出现Error: Error parsing C:\Users\admin*\.android\devices.xml
Error: Error parsing C:\Users\admin*\.android\devices.xml 在ADT eclipse打开项目的时候出现此提示,但是又不影响使用. 原因:之前安 ...
- adb shell出现error错误
模拟器已打开,原因在于端口被占用. 找到kadb.exe 进程,结束进程!
- [sql server、oracle] 分组取最大值最小值常用sql
sqlserver2005前: --分组取最大最小常用sql--测试环境if OBJECT_ID('tb') is not null drop table tb;gocreate table tb( ...
- mysql安装篇
装了vps,环境又要自己配置.mysql比较难装上. 1.安装MySQL 5.5.x的yum源:rpm -Uvh http://repo.webtatic.com/yum/centos/5/lates ...
- 【POJ】【2125】Destroying the Graph
网络流/二分图最小点权覆盖 果然还是应该先看下胡伯涛的论文…… orz proverbs 题意: N个点M条边的有向图,给出如下两种操作.删除点i的所有出边,代价是Ai.删除点j的所有入边,代价是Bj ...
- RAD项目结构
- SPOJ NSUBSTR Substrings 后缀自动机
人生第一道后缀自动机,总是值得纪念的嘛.. 后缀自动机学了很久很久,先是看CJL的论文,看懂了很多概念,关于right集,关于pre,关于自动机的术语,关于为什么它是线性的结点,线性的连边.许多铺垫的 ...
- hdu 1596 find the safest road(最短路,模版题)
题目 这是用Dijsktra做的,稍加改动就好,1000ms..好水.. #define _CRT_SECURE_NO_WARNINGS #include<string.h> #inclu ...
- HDU 2136 Largest prime factor(查找素数,筛选法)
题目梗概:求1000000以内任意数的最大质因数是第几个素数,其中 定义 1为第0个,2为第1个,以此类推. #include<string.h> #include<stdio.h& ...
- ZOJ 3791 An Easy Game(DP)
题目链接 题意 : 给你两个长度为N的字符串,将第一个字符串每次只能变化M个,问变换K次之后变成第二个字符串一共有几种方法. 思路 : DP.dp[i][j]表示变了 i 次之后有j个不一样的字母的方 ...