Another lottery
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的更多相关文章
- UVA10325 The Lottery(容斥原理)
题意: 给n,m,和m个数(k1~km).求1~n中有多少个数不是(k1~km)中任意一数的倍数. 题解: 容斥模板题.反面考虑,a的倍数有n/a个:既是a,也是b的倍数,即lcm(a,b)的倍数有n ...
- EX14 彩票中奖 (lottery.pas/c/cpp)
[题目描述]小明想试试运气去购买彩票,所以他开始研究彩票大乐透的玩法:超级大乐透是指由购买者从01—35共35个号码中选取5个号码为前区号码,并从01—12共12个号码中选取2个号码为后区号码组合为一 ...
- UVA 10325 The Lottery( 容斥原理)
The Sports Association of Bangladesh is in great problem with their latest lottery `Jodi laiga Jai'. ...
- Java基础之处理事件——选项按钮的鼠标监听器(Lottery 2 with mouse listener)
控制台程序. 定义监听器类有许多方式.下面把监听器类定义为单独的类MouseHandler: // Mouse event handler for a selection button import ...
- Java基础之处理事件——applet中语义事件的处理(Lottery 1)
控制台程序. 语义事件与程序GUI上的组件操作有关.例如,如果选择菜单项或单击按钮,就会生成语义事件. 对组件执行操作时,例如选择菜单项或单击按钮,就会生成ActionEvent事件.在选择或取消选择 ...
- php 彩票类 lottery
<?php /* * For the full copyright and license information, please view the LICENSE * file that wa ...
- 今天分享一个抽奖的类Lottery
/* * Copyright (C) 2014 Jason Fang ( ijasonfang@gmail.com ) * * Licensed under the Apache License, V ...
- hdu 1099 Lottery
这是我第一次写博客,作为一个ACMer,经常进别人的博客,所以自己也想写写博客. HDU 1099 Lottery Time Limit: 2000/1000 MS (Java/Others) ...
- uva - The Lottery(容斥,好题)
10325 - The Lottery The Sports Association of Bangladesh is in great problem with their latest lotte ...
- 2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest I Lottery
LotteryCrawling in process... Crawling failed Time Limit:2000MS Memory Limit:524288KB 64bit ...
随机推荐
- Re0:DP学习之路 01背包如何打印路径?
伪代码 用二维数组记录,如果出现可以转移的dp那么记录bk[当前体积][装的物品]=1 输出的时候倒推,如果存在连通的边那么输出并且总共的体积减去输出的体积 代码(uva-624,目前wa不明所以,网 ...
- knockout.js--基本用法
1,HTML元素的面向对象的赋值,数据绑定 text绑定:为p,span,div,td等加text属性值(即元素内部显示的文本), value绑定:为input添加value属性值, attr绑定:为 ...
- calculate Cp history (from Fluent) using Matlab
input data : unscaled time history of moment/thrust from ANSYS fluent example of input data, "m ...
- c++行事准则
1.c++包含多种编程范式,每种范式遵循不同的准则: 2.除了#include和#ifdef之流,其他预处理器别用,多用enum和const: 3.函数声明定义多用const:
- [bzoj4521][Cqoi2016][手机号码] (数位dp+记忆化搜索)
Description 人们选择手机号码时都希望号码好记.吉利.比如号码中含有几位相邻的相同数字.不含谐音不 吉利的数字等.手机运营商在发行新号码时也会考虑这些因素,从号段中选取含有某些特征的号 码单 ...
- SRAM的简单概念
CY7C138 版权声明:本文为博主原创文章,未经博主允许不得转载.
- Springboot druid监控配置
@Configuration public class DataSourceConfig { @Bean public ServletRegistrationBean statViewServlet( ...
- spring boot 的使用(一)
1. 启动spring-boot项目 mvn spring-boot:run cd target java -jar xxxx.jar xxxx代表生成的jar包
- java 访问对象私有变量
Captcha captcha = getCaptcha(captchaId); // 通过反射获取验证码值 Class<?> classType = captcha.getClass() ...
- [poj3537]Crosses and Crosses_博弈论
Crosses and Crosses poj-3537 题目大意:给定一个1*n的网格,每次往格子内填一个$\times$,连续的三个即可获胜. 注释:$1\le n\le 2000$. 想法:我们 ...