直接枚举

-------------------------------------------------------------------------------

#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

BZOJ 1599: [Usaco2008 Oct]笨重的石子( 枚举 )的更多相关文章

  1. bzoj 1599: [Usaco2008 Oct]笨重的石子【枚举】

    --我为什么要写这种题解-- 枚举投掷情况即可 #include<iostream> #include<cstdio> using namespace std; int s1, ...

  2. 1599: [Usaco2008 Oct]笨重的石子

    1599: [Usaco2008 Oct]笨重的石子 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 795  Solved: 543[Submit][ ...

  3. BZOJ1599: [Usaco2008 Oct]笨重的石子

    1599: [Usaco2008 Oct]笨重的石子 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 758  Solved: 513[Submit][ ...

  4. bzoj 1602 [Usaco2008 Oct]牧场行走(LCA模板)

    1602: [Usaco2008 Oct]牧场行走 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 379  Solved: 216[Submit][Sta ...

  5. BZOJ 1602: [Usaco2008 Oct]牧场行走( 最短路 )

    一棵树..或许用LCA比较好吧...但是我懒...写了个dijkstra也过了.. ---------------------------------------------------------- ...

  6. BZOJ 1600: [Usaco2008 Oct]建造栅栏( dp )

    QAQ我没读过书...四边形都不会判定了 简单的dp.... --------------------------------------------------------------------- ...

  7. BZOJ 1603: [Usaco2008 Oct]打谷机

    题目 1603: [Usaco2008 Oct]打谷机 Time Limit: 5 Sec  Memory Limit: 64 MB Description Farmer John有一个过时的打谷机( ...

  8. BZOJ 1601 [Usaco2008 Oct]灌水

    1601: [Usaco2008 Oct]灌水 Time Limit: 5 Sec  Memory Limit: 162 MB Description Farmer John已经决定把水灌到他的n(1 ...

  9. BZOJ 1600: [Usaco2008 Oct]建造栅栏

    1600: [Usaco2008 Oct]建造栅栏 Time Limit: 5 Sec  Memory Limit: 64 MB Description 勤奋的Farmer John想要建造一个四面的 ...

随机推荐

  1. SpringMVC入门一:helloWorld

    玩了一下SpringMVC, 感觉挺清爽的 好像没有struts那么臃肿( 可能是高级的东西我还不会用 哈 ) 例子中一共有俩方法: 一个Controller直接返回字串的方法, 另一个通过Dao层返 ...

  2. PHP中的一个很好用的文件上传类

    <?php    class FileUpload{      private $filepath; //设置上传文件的路径   private $allowtype=array('jpg',' ...

  3. gdbserver 安卓apk

    gdbserver  调试程序 底层调用c/c++ 动态库, 动态库带调试选项 查看手机IP 192.168.1.177 包所调用的c/c++ 库是在/data/data/包名/lib/ 下 1.将安 ...

  4. Google Maps 学习笔记(一)2014.06.04

    1.<body onload="加载地图的函数" onunload="GUnload()"> 2.new GMap2(container,opts) ...

  5. SDK无法更新

    http://jingyan.baidu.com/article/da1091fbd232fe027949d653.html

  6. mac的svn之cornerstone简易教程

    链接地址:http://jingyan.baidu.com/article/9989c74612a55af648ecfef2.html 背景: 关于cornerstone的介绍很少: 这里介绍mac的 ...

  7. JavaSE_ 反射 目录(27)

    JavaSE学习总结第27天_反射 & 设计模式 & JDK5.7.8新特性27.01 反射_类的加载概述和加载时机27.02 反射_类加载器的概述和分类27.03 反射_反射概述27 ...

  8. 关于Python的self指向性

    Python的self是指向类的实例化对像,而不是类本身,每次调用类的实例化即self指向此实例化对像,如下代码: class Person: def __init__(self,name): sel ...

  9. python函数callable

    callable(object) 中文说明:检查对象object是否可调用.如果返回True,object仍然可能调用失败:但如果返回False,调用对象ojbect绝对不会成功. 注意:类或函数是可 ...

  10. PowerShell Remove all user defined variable in PowerShell

    When PS scripts executes, it is possibly create much user defined variables. So, sometimes these var ...