程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> URAL1961:Cantonese Dialect

URAL1961:Cantonese Dialect

編輯:C++入門知識

URAL1961:Cantonese Dialect


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


題意:隨機選n個人,有m個說土話,問總共N個人,有幾個講土話 思路:概率問題,要考慮小數取捨
#include 
#include 
#include 
#include 
#include 
#include
#include 
#include 
#include 
#include 
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;
}


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved