您的位置:首页 > 其它

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 MB
Submit: 820 Solved: 561
[Submit][Status][Discuss]

Description

贝西喜欢棋盘游戏和角色扮演类游戏所以她说服Farmer John把她带到玩具店,在那里,她购买了三个不同的骰子,这三个质量均匀的骰子,分别有S1,S2,S3个面。(2 <= S1 <= 20; 2 <= S2 <= 20; 2 <= S3 <= 40). 贝西掷啊掷啊掷啊,想要知道出现几率最大的和是多少。 问题给出三个骰子的面数,让你求出出现几率最大的和是多少。如果有很多种和出现的几率相同,那么就输出小的那一个。

Input

*第一行:三个由空格隔开的整数:s1,s2,s3

Output

*第一行:所要求的解

Sample Input

3 2 3

Sample 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

资格赛
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: