URAL1961:Cantonese Dialect
2015-04-19 21:59
281 查看
Open Ural FU Personal Contest 2013
After some thought on where to spend a holiday Vova decided to travel around South China and visit Guangzhou, Shenzhen, Macau and Hong Kong.Vova heard that South China speaks the Cantonese dialect of the Chinese language. So before setting off he learned several simple phrases in Cantonese. During his first walk around the Guangzhou center Vova said hello to n passers-by
and m of them responded. Vova concluded that the other (n − m)
passers-by, obviously, spoke the Mandarin dialect of the Chinese language.
After Vova finished his walk, he decided to evaluate M, the number of Guangzhou citizens who speak Cantonese. Wikipedia states that the city's population is N people.
Help Vova to find such M, which maximizes the probability that exactly m out of n random
passers-by speak Cantonese.
Input
The single input line contains integers n, m and N (1≤ n ≤ N ≤ 108; 0 ≤ m ≤ n).
Each of the n passers-by was a Guangzhou citizen and met Vova exactly once during the walk.
Output
Print the required M. If there are multiple values of M maximizing the probability, print the largest of them.
Sample Input
input | output |
---|---|
10 1 200 | 20 |
思路:概率问题,要考虑小数取舍
#include <iostream> #include <stdio.h> #include <string.h> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <math.h> #include <algorithm> using namespace std; #define ls 2*i #define rs 2*i+1 #define up(i,x,y) for(i=x;i<=y;i++) #define down(i,x,y) for(i=x;i>=y;i--) #define mem(a,x) memset(a,x,sizeof(a)) #define w(a) while(a) #define LL long long const double pi = acos(-1.0); #define Len 200005 #define mod 19999997 const int INF = 0x3f3f3f3f; LL n,m,N,M; int main() { w(~scanf("%I64d%I64d%I64d",&n,&m,&N)) { M = (N+1)*m/n; if(M>N) M = N; printf("%I64d\n",M); } return 0; }
相关文章推荐
- Ural 1961 Cantonese Dialect
- cugb.20140417 (ural 1961 - 1970)
- Ural1353-Milliard Vasya's Function
- ural 1136. Parliament -搜索二叉树
- ural 1149
- Timus Online Judge:ural:1006. Square Frames
- URAL 1553 Caves and Tunnels(LCT动态树)
- POJ 1961Period(KMP算法)
- URAL1696 Salary for Robots
- Ural 2070 Interesting Numbers
- ural1010 Discrete Function
- URAL 2068. Game of Nuts
- 简单树形动态规划(ural 1039 没有上司的晚会)
- POJ 1961 KMP求循环节判断循环
- URAL 1998 The old Padawan
- Ural 1260 A nudnik photographer(DP)
- URAL - 2018 The Debut Album (递推)
- ural 2014 Zhenya moves from parents
- URAL 2015 Zhenya moves from the dormitory(水题)
- POJ - 1961 Period解题报告(kmp next数组巧用)