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 ...
随机推荐
- Jenkins部署.NET网站项目
Jenkins Jenkins是一个开源软件项目,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能. Jenkins是基于Java开发的一种持续集成工具,用于监控持续重复的工作,功能包括: 持 ...
- C# 数据结构--排序[上]
概述 看了几天的排序内容,现在和大家分享一些常见的排序方法. 啥是排序? 个人理解的排序:通过对数组中的值进行对比,交换位置最终得到一个有序的数组.排序分为内存排序和外部排序.本次分享排序方法都为内存 ...
- [CF]codeforces round#366(div2)滚粗记
开场心理活动:啊打完这场大概有1700了吧 中途心理活动:啊这个ABC看起来都随便做啊 死亡原因:欸怎么没网了 -75 .. A [题意]Hulk说完一句I hate会说that I love 然后是 ...
- Java学习第四篇:数组,排序,查找
一.数组 1.一维数组 (1).数组的定义 数据类型 数组名[]=new 数据类型[大小] public class Demo1 { public static void main(String[] ...
- Android Dock底座应用开发
很多网友可能发现部分Android手机或平板支持底座,目前比较主流的有摩托罗拉系列,中低端的Milestone和Milestone 2代均可以使用充电底座或多媒体底座,网购大概50元左右.而中高端的A ...
- 【C++基础】sizeof 与 strlen的区别
要理解两者的区别,就要分别理解他们的本质 strlen(char *) 计算字符串的长度,内部实现是用一个循环计算字符串的长度,直到‘\0’为止 1.srtlen 是一个函数,参数只能为char 或者 ...
- python参考手册--第1章python简介
1.if __name__ == '__main__': 直接运行myModel.py时,当前模块的名字是main:import myModel然后运行的时候当前模块的名字是myModel. 2.ev ...
- 03 - 运行OCCI测试程序遇到0xc0150002错误
通过控制面板->管理工具->Event Viewer->Windows Log->Application Logs, 可以看到可以看到是如下错误 “C:\Windows\ora ...
- Vimrc配置以及Vim的常用操作
""""""""""""""""&quo ...
- python 利用imap接收邮件,并保存附件
def SaveAttachImap():# login the imap server ,retrive the new mails ,and download the attachments. ...