http://acm.hdu.edu.cn/showproblem.php?pid=2985

题意:有n个人每个人可以买m轮彩票,每轮可以买尽可能多的彩票。如果该彩票在i轮被抽到,则该人可以获得2^i的奖金,问该人获得的奖金数比其他人都高的概率。

思路:如果该人在第m轮中奖,则他获得的奖金数最高,如果m轮没人买彩票,则在m-1轮中奖奖金数最高。。以此类推。。求出在该轮的中奖概率即可。最后的分数输出形式通过最大公约数化简。

 #include <stdio.h>
#include <string.h>
#include <algorithm>
#define LL __int64
using namespace std;
const int N=;
LL a[N][];
LL p[N];
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m))
{
LL sum = ;
if (n==&&m==)
break;
for (int i = ; i < n; i++)
{
for (int j = ; j < m; j++)
{
scanf("%I64d",&a[i][j]);
}
}
while(!sum)
{
for (int i = ; i < n; i++)
{
sum+=a[i][m-];
p[i] = a[i][m-];
}
m--;
}
for (int i = ; i < n; i++)
{
LL temp = __gcd(sum,p[i]);
LL r1 = p[i]/temp;
LL r2 = sum/temp;
printf("%I64d / %I64d\n",r1,r2);
}
}
return ;
}

Another lottery的更多相关文章

  1. UVA10325 The Lottery(容斥原理)

    题意: 给n,m,和m个数(k1~km).求1~n中有多少个数不是(k1~km)中任意一数的倍数. 题解: 容斥模板题.反面考虑,a的倍数有n/a个:既是a,也是b的倍数,即lcm(a,b)的倍数有n ...

  2. EX14 彩票中奖 (lottery.pas/c/cpp)

    [题目描述]小明想试试运气去购买彩票,所以他开始研究彩票大乐透的玩法:超级大乐透是指由购买者从01—35共35个号码中选取5个号码为前区号码,并从01—12共12个号码中选取2个号码为后区号码组合为一 ...

  3. UVA 10325 The Lottery( 容斥原理)

    The Sports Association of Bangladesh is in great problem with their latest lottery `Jodi laiga Jai'. ...

  4. Java基础之处理事件——选项按钮的鼠标监听器(Lottery 2 with mouse listener)

    控制台程序. 定义监听器类有许多方式.下面把监听器类定义为单独的类MouseHandler: // Mouse event handler for a selection button import ...

  5. Java基础之处理事件——applet中语义事件的处理(Lottery 1)

    控制台程序. 语义事件与程序GUI上的组件操作有关.例如,如果选择菜单项或单击按钮,就会生成语义事件. 对组件执行操作时,例如选择菜单项或单击按钮,就会生成ActionEvent事件.在选择或取消选择 ...

  6. php 彩票类 lottery

    <?php /* * For the full copyright and license information, please view the LICENSE * file that wa ...

  7. 今天分享一个抽奖的类Lottery

    /* * Copyright (C) 2014 Jason Fang ( ijasonfang@gmail.com ) * * Licensed under the Apache License, V ...

  8. hdu 1099 Lottery

    这是我第一次写博客,作为一个ACMer,经常进别人的博客,所以自己也想写写博客. HDU 1099 Lottery Time Limit: 2000/1000 MS (Java/Others)     ...

  9. uva - The Lottery(容斥,好题)

    10325 - The Lottery The Sports Association of Bangladesh is in great problem with their latest lotte ...

  10. 2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest I Lottery

    LotteryCrawling in process... Crawling failed Time Limit:2000MS     Memory Limit:524288KB     64bit ...

随机推荐

  1. enote笔记法的思考

    章节:enote笔记法的思考   why enote笔记法: key1)大脑喜欢颜色. 我们的大脑天生就喜欢颜色.对颜色很敏感,这是由我们人类过去的演化历程决定的. 你可以理解为,文字有了颜色,让这个 ...

  2. UVA - 11536 Smallest Sub-Array(尺取法)

    题目: 思路: 读完题之后第一时间想到的是尺取法来做这个题,结果让自己写写崩了,还是练得少!! 到网上搜了一下学习了大佬的标记方法,用一个变量来判断是不是都已经出现,要比每次都判断一下快超多. 代码: ...

  3. HDU - 5952 Counting Cliques(dfs搜索)

    题目: A clique is a complete graph, in which there is an edge between every pair of the vertices. Give ...

  4. rem js 自适应布局

    (function(doc, win) { resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',//o ...

  5. Linux文件/目录,权限相关

    查看权限 命令 # ls -l filename 结果 -rw-r--r-- l root root 27 11-10 14:50 filename 解析: -rw-r--r-- --共10位 第1位 ...

  6. ubutun 创建左面快捷方式

    #http://blog.csdn.net/jizi7618937/article/details/51012552

  7. BZOJ 1012 洛谷1198 最大数 maxnumber

    用线段数维护即可 #include<cstdio> #include<algorithm> #define ls (cur<<1) #define rs (cur& ...

  8. Python学习笔记 (2)变量、常量和数据类型

    变量 顾名思义,变量就是一个会变的量,用一个变量名表示,指向内存中一片区域,而指向的区域存的是什么,这个变量就是什么数据类型,和C/C++挺不一样的.变量数据类型可以通过赋值变来变去(这就叫动态语言, ...

  9. noip模拟赛 蒜头君救人

    分析:之前的一道模拟赛题是dp+dfs,这道题是dp+bfs. 我们设f[stu][i][j]为当前状态为stu,走到(i,j)的答案,考虑怎么设计stu,每个人的状态有3种:要么在原地,要么被背着, ...

  10. vue用js部分控制动画实现

    上次我们提到用vue实现过渡动画,其实只讲了vue动画的一部分,用vue自带的css状态控制动画实现,不带js http://www.cnblogs.com/null11/p/7081506.html ...