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. [Algorithm] 10. Reverse Integer

    Description Given a 32-bit signed integer, reverse digits of an integer. Example Example 1: Input: 1 ...

  2. 一篇入门Express

    目录 1.安装 2.Hello World 3.基础路由设置 4.高级路由设置 5.静态文件 6.中间件 7.生成器 1.安装 Express 是一个 基于 Node.js 的简洁灵活的 Web 应用 ...

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

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

  4. The turtle Module 一个画图的模块

    感悟: 这样写的介绍才有用 import turtle bob = turtle.Turtle() print(bob) turtle.mainloop() Turtle()方法打开一个窗口,中间带有 ...

  5. PyQt5Icon图标(Icon)无法显示问题

    PyQt5中设置图标无法显示 以下源码来源PyQt5教程http://zetcode.com/gui/pyqt5/firstprograms/ import sys from PyQt5.QtWidg ...

  6. mesh topology for airfoil, wing, blade, turbo

    ref Ch. 5, Anderson, CFD the basics with applications numerical grid generation foundations and appl ...

  7. Codeforces 990D - Graph And Its Complement

    传送门:http://codeforces.com/contest/990/problem/D 这是一个构造问题. 构造一张n阶简单无向图G,使得其连通分支个数为a,且其补图的连通分支个数为b. 对于 ...

  8. RabbitMq的简单使用

    本篇将介绍RabbitMq的一个简单使用例子,分别介绍生产者如何发送消息,消费者如何接收和处理消息 关于RabbitMQ的知识背景的文章非常多.我对它的总结是,解决高并发请求的瓶颈,将应用程序真正处理 ...

  9. Mysql 练习题 及 答案

    --1.学生表 Student(S,Sname,Sage,Ssex) --S 学生编号,Sname 学生姓名,Sage 出生年月,Ssex 学生性别 --2.课程表  Course(C,Cname,T ...

  10. Sky数

    Problem Description Sky从小喜欢奇特的东西,而且天生对数字特别敏感,一次偶然的机会,他发现了一个有趣的四位数2992,这个数,它的十进制数表示,其四位数字之和为2+9+9+2=2 ...