BZOJ 1599: [Usaco2008 Oct]笨重的石子( 枚举 )
2015-06-06 14:17
148 查看
直接枚举
-------------------------------------------------------------------------------
#include<cstdio>#include<cstring>#include<algorithm>#include<iostream> #define rep( i , n ) for( int i = 0 ; i < n ; ++i )#define clr( x , c ) memset( x , c , sizeof( x ) )#define Rep( i , n ) for( int i = 1 ; i<= n ; ++i ) using namespace std; const int maxn = 80 + 5; int cnt[ maxn ];
int main() { clr( cnt , 0 ); int x[ 3 ]; rep( i , 3 ) scanf( "%d" , x + i ); Rep( i , x[ 0 ] ) Rep( j , x[ 1 ] ) Rep( k , x[ 2 ] ) cnt[ i + j + k ]++; int Max = 0 , ans; rep( i , maxn ) if( cnt[ i ] > Max ) Max = cnt[ ans = i ]; cout << ans << "\n"; return 0;}
-------------------------------------------------------------------------------
1599: [Usaco2008 Oct]笨重的石子
Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 820 Solved: 561
[Submit][Status][Discuss]
Description
贝西喜欢棋盘游戏和角色扮演类游戏所以她说服Farmer John把她带到玩具店,在那里,她购买了三个不同的骰子,这三个质量均匀的骰子,分别有S1,S2,S3个面。(2 <= S1 <= 20; 2 <= S2 <= 20; 2 <= S3 <= 40). 贝西掷啊掷啊掷啊,想要知道出现几率最大的和是多少。 问题给出三个骰子的面数,让你求出出现几率最大的和是多少。如果有很多种和出现的几率相同,那么就输出小的那一个。Input
*第一行:三个由空格隔开的整数:s1,s2,s3Output
*第一行:所要求的解Sample Input
3 2 3Sample Output
5输出详解:
这里是所有可能的情况.
1 1 1 -> 3 1 2 1 -> 4 2 1 1 -> 4 2 2 1 -> 5 3 1 1 -> 5 3 2 1 -> 6
1 1 2 -> 4 1 2 2 -> 5 2 1 2 -> 5 2 2 2 -> 6 3 1 2 -> 6 3 2 2 -> 7
1 1 3 -> 5 1 2 3 -> 6 2 1 3 -> 6 2 2 3 -> 7 3 1 3 -> 7 3 2 3 -> 8
5和6出现的几率都是最大的,所以输出5.
HINT
Source
资格赛相关文章推荐
- wamp多站点配置
- Dependency Walker使用说明
- poj 2431 poj 3253 优先队列的运用
- MFC对话框中的单选按钮(Radio)
- Android屏幕适配全攻略(最权威的官方适配指导)
- ubuntu14.04拼音输入法问题的解决方法
- 添加persist.sys属性写权限方法
- HTML标题标签和特殊的字符
- Spring MVC实现查找酒店用例
- vagrant启动报错The following SSH command responded with a non-zero exit status.,vagrantnon-zero
- mysql相关问题
- WebRTC代码走读(八):代码目录结构
- 程序向mysql插入中文乱码解决办法
- Django学习日记01_环境搭建
- C:\\MFC控件大小随窗体大小而改变
- AutoCAD .NET二次开发(一)
- Mysql中左连接
- VNC connect to raspberry pi under ubuntu desktop environment
- Hadoop学习笔记(十四)---Hbase集群安装及配置
- 浅谈 React Native