Dice Cup

题目链接:

http://acm.hust.edu.cn/vjudge/contest/127406#problem/D

Description


In many table-top games it is common to use different dice to simulate random events. A “d” or “D”
is used to indicate a die with a specific number of faces, d4 indicating a four-sided die, for example.
If several dice of the same type are to be rolled, this is indicated by a leading number specifying the
number of dice. Hence, 2d6 means the player should roll two six-sided dice and sum the result face
values.
Write a program to compute the most likely outcomes for the sum of two dice rolls. Assume each
die has numbered faces starting at 1 and that each face has equal roll probability.

Input


The input file contains several test cases, each of them as described below.
The input consists of a single line with two integer numbers, N, M, specifying the number of faces
of the two dice.
Constraints:
4 ≤ N, M ≤ 20 Number of faces.

Output


For each test case, a line with the most likely outcome for the sum; in case of several outcomes with
the same probability, they must be listed from lowest to highest value in separate lines.
The outputs of two consecutive cases will be separated by a blank line.

Sample Input


6 6
6 4
12 20

Sample Output


7
5
6
7
13
14
15
16
17
18
19
20
21


##题意:

分别掷一个N面和M面的骰子.
求出现概率最大的顶面数和.


##题解:

直接模拟一遍记录所有顶面数之和.
把出现次数最多的数从小到大输出.


##代码:
``` cpp
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define LL long long
#define eps 1e-8
#define maxn 101000
#define mod 100000007
#define inf 0x3f3f3f3f
#define mid(a,b) ((a+b)>>1)
#define IN freopen("in.txt","r",stdin);
using namespace std;

int cnt[100];

int main(int argc, char const *argv[])

{

//IN;

int n, m;
int flag = 0;
while(scanf("%d %d", &n,&m) != EOF)
{
memset(cnt, 0, sizeof(cnt)); for(int i=1; i<=n; i++) {
for(int j=1; j<=m; j++) {
cnt[i+j]++;
}
} if(flag) printf("\n");
flag = 1; int ma = 0;
for(int i=0; i<=n+m; i++) ma = max(ma, cnt[i]);
for(int i=0; i<=n+m; i++) {
if(cnt[i] == ma)
printf("%d\n", i);
}
} return 0;

}

UVALive 7275 Dice Cup (水题)的更多相关文章

  1. LightOJ 1248 Dice (III) (水题,期望DP)

    题意:给出一个n面的色子,问看到每个面的投掷次数期望是多少. 析:这个题很水啊,就是他解释样例解释的太...我鄙视他,,,,, dp[i] 表示 已经看到 i 面的期望是多少,然后两种选择一种是看到新 ...

  2. UVaLive 6608 Cabin Baggage (水题)

    题意:给定四个数代表长宽高和重,问你是不是满足下面条件,长不高于56,宽不宽于45,高不高于25,或者总和不大于125,并且重量不高于7. 析:判断输出就好,注意这个题是或,不要想错了. 代码如下: ...

  3. UVALive 4764 简单dp水题(也可以暴力求解)

    B - Bing it Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status ...

  4. UVaLive 6802 Turtle Graphics (水题,模拟)

    题意:给定一个坐标,和一行命令,按照命令走,问你有多少点会被访问超过一次. 析:很简单么,按命令模拟就好,注意有的点可能走了多次,只能记作一次. 代码如下: #pragma comment(linke ...

  5. UVaLive 6858 Frame (水题)

    题意:给定一个矩形框架,给定一个小矩形,问你能不能正好拼起来. 析:很简单么,就三种情况,如果是1*1的矩形,或者是1*2的一定可以,然后就是上面和下面正好能是小矩形的整数倍,左右是少一,两个就是整数 ...

  6. Argus UVALive - 3135(优先队列 水题一道)

    有一系列的事件,它每Period秒钟就会产生编号为qNum的事件,你的任务是模拟出前k个事件,如果多个事件同时发生,先处理qNum小的事件 今天再看看数据结构.. #include <iostr ...

  7. UVa 12709 && UVaLive 6650 Falling Ants (水题)

    题意:给定 n 个长方体的长,宽,高,让你求高最大的时候体积最大是多少. 析:排序,用高和体积排序就好. 代码如下: #pragma comment(linker, "/STACK:1024 ...

  8. UVALive 6858——分类讨论&&水题

    题目 链接 题意:对于一个$n \times m$的矩阵的最外一圈,问是否能用$k \times 1$的方块填满 分析 考虑左右两边的情况,分类讨论,切记考虑所有可能的情形. #include< ...

  9. UVALive 6862——结论题&&水题

    题目 链接 题意:求满足$0 \leq x \leq y \leq z \leq m$且$x^j + y^j = z^j, \ j=2 \cdots n$的三元组的对数 分析 由费马大定理:整数$n ...

随机推荐

  1. 传感器(3)传感器的X,Y,Z轴

    设备正面水平向上. X轴 : 左右方向,向右是正值. Y轴 : 远近方向,远离你是负. Z轴 : 上下方向,向上是正值.

  2. Android权限安全(11)内置计费相关安全要点

    内置计费相关安全要点 1.计费Server接口保密且Transiction 加密 (SSL) 2.仅允许配套的安全本地组件(通常是第三方付费sdk如支付宝)与计费Server通信,且安全本地组件负责与 ...

  3. 使用git对unity3d项目进行版本控制

    http://stackoverflow.com/questions/18225126/how-to-use-git-for-unity-source-control The following is ...

  4. Codeforces Round #242 (Div. 2) C. Magic Formulas (位异或性质 找规律)

    题目 比赛的时候找出规律了,但是找的有点慢了,写代码的时候出了问题,也没交对,还掉分了.... 还是先总结一下位移或的性质吧: 1.  交换律 a ^ b = b ^ a 2. 结合律 (a^b) ^ ...

  5. ACM - ICPC World Finals 2013 B Hey, Better Bettor

    原题下载:http://icpc.baylor.edu/download/worldfinals/problems/icpc2013.pdf 这题真心的麻烦……程序不长但是推导过程比较复杂,不太好想 ...

  6. JAVA将Excel中的报表导出为图片格式(二)实现思路

    接上文,一封类似于下方设计的Excel报表,如何将它指定的区域导出为样式一模一样的JPG图片呢? 要实现这个功能没有现成的解决方案,谷歌度娘了好久也没有,最终自己想了几条思路: 思路1:将报表中的背景 ...

  7. ti processor sdk linux am335x evm /bin/setup-tftp.sh hacking

    #!/bin/sh # # ti processor sdk linux am335x evm /bin/setup-tftp.sh hacking # 说明: # 本文主要对TI的sdk中的setu ...

  8. acdream 1684 娜娜梦游仙境系列——莫名其妙的插曲 (gcd)

    题意:一开始有一个集合,集合里有n个不同的数,然后Alice(娜娜)与Bob轮流进行操作,每人都可以任意选择两个数a,b,不妨设a>b,不过要求a-b不在集合中,把a-b放入集合(集合元素个数只 ...

  9. 最简单的视音频播放示例4:Direct3D播放RGB(通过Texture)

    本文接着上一篇文章继续记录Direct3D(简称D3D)播放视频的技术.上一篇文章中已经记录了使用Direct3D中的Surface渲染视频的技术.本文记录一种稍微复杂但是更加灵活的渲染视频的方式:使 ...

  10. Oracle中job的使用详解

    我们在项目开发中,常常会有一些复杂的业务逻辑.使用oracle的存储过程,可以大大减少java程序代码的编写工作量,而且存储过程执行在数据库上,这样可以利用oracle的良好性能支持,极大地提高程序执 ...