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. Jquery ajax请求导出Excel表格

    直接贴代码吧 $("#btn-export").click(function(){ var exportExcel = "export_excel"; data ...

  2. C#笔记1:异常

    reference : http://www.cnblogs.com/luminji/archive/2010/10/20/1823536.html 本章概要: 1:为什么需要异常 2:finally ...

  3. 文本编辑器 markdown

    http://www.cnblogs.com/youxia/p/linux014.html markdown对数学公式的支持http://www.linuxidc.com/Linux/2014-08/ ...

  4. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) D. Little Artem and Dance

    题目链接: http://codeforces.com/contest/669/problem/D 题意: 给你一个初始序列:1,2,3,...,n. 现在有两种操作: 1.循环左移,循环右移. 2. ...

  5. 【锋利的JQuery-学习笔记】添加提示图片

    效果图: hot图片: (注意:这个图标本身就有抖动效果的,并不是由于标签<del>而具有抖动效果) 周期性抖动,起到提示的作用 html: <div class="jnC ...

  6. mysql数据库主外键级联删除脚本RESTRICT --> CASCADE

    在项目中,我们一般在数据库设计的时候做主外键关联设计,要么就不做.但是这样不符合规范,呵呵. 建立主外键关系的时候,默认是不能级联删除的.而出现往往在删除主表的数据时报错, 需要先删除从表然后再删除主 ...

  7. C++中的const关键字

    http://blog.csdn.net/eric_jo/article/details/4138548 C++中的const关键字的用法非常灵活,而使用const将大大改善程序的健壮性,本人根据各方 ...

  8. 读写txt文件

    public void SetUpdateTime(string strNewDate) { try { var path =Application.StartupPath + Configurati ...

  9. TopCoder 649 div1 & div2

    最近一场TC,做得是在是烂,不过最后challenge阶段用一个随机数据cha了一个明显错误的代码,最后免于暴跌rating,还涨了一点.TC题目质量还是很高的,非常锻炼思维,拓展做题的视野,老老实实 ...

  10. cojs 简单的最近公共祖先 解题报告

    我曾经自己想过每考试一次就从考试题中找找idea来出题 这次又找到了一个,先不管原来的考试题是什么 考试题中其中的一部分就是今天的这道题目啦 当时考场上自己比较傻,没有注意到有用的性质,套用了之前黑白 ...