URAL1961:Cantonese Dialect

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 <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;
}

时间: 2024-08-06 03:42:09

URAL1961:Cantonese Dialect的相关文章

dialect和Cantonese:土话与方言

一. dialect:方言 1.土话 土话是指在某一区域的当地人使用的方言, 如广东话.上海话等,其发音与普通话差别很大.土语一般只在同类人群中使用,而在公共场合常用普通话交流. 2.地方话 地方话指的是一个国家或地区所使用的语言.在广义语言学里,地方话被用来形容相对于官方标准语言和世界语言的语言. 3.数据库方言 在数据库中,标准的SQL语句就是国语.官话,在所有数据是通用的,而每个数据库又有自己独有的一些SQL语法,这就相当于每个地方的人有自己的方言.数据库方言就是dialect这个词. 二

Hibernate的Dialect对应各数据库的设置

RDBMS 方言 DB2 org.hibernate.dialect.DB2Dialect DB2 AS/400 org.hibernate.dialect.DB2400Dialect DB2 OS390 org.hibernate.dialect.DB2390Dialect PostgreSQL org.hibernate.dialect.PostgreSQLDialect MySQL org.hibernate.dialect.MySQLDialect MySQL with InnoDB o

hibernate 加载 jdbc驱动出错Access to DialectResolutionInfo cannot be null when &#39;hibernate.dialect&#39; not set

Exception in thread "main" org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set程序基本没动过,以前用的3.3.2的版本,今天换成4.3.4的版本后,改了一下sessionFactory的生成方法,其他的不变,开始还能运行,过了30min左右,就不能运行了! hibernate4 已经废弃

&#39;hibernate.dialect&#39; must be set when no Connection available

今天碰到的这个问题,很无厘头,网上搜索了很多,都不靠谱,还是靠自己 解决方法是在hibernate.cfg.xml中添加 <property name="dialect"> org.hibernate.dialect.MySQLInnoDBDialect </property> 'hibernate.dialect' must be set when no Connection available

atitit. hb 原生sql跨数据库解决原理 获得hb 数据库类型运行期获得Dialect

#-----原理 Hibernate 运行期获得Dialect 2010-07-28 12:59:58|  分类: 软件开发 |举报 |字号 订阅 String dialect = ((SessionFactoryImpl) session.getSessionFactory()).getDialect() .getClass().getName(); //     //org.hibernate.dialect.MySQLDialect 如果是spring + hibernate则可以: St

Hibernate SQL方言 (hibernate.dialect) Spring配置文件applicationContext.xml

转自:http://www.cnblogs.com/wj-wangjun/archive/2009/10/21/1587624.html Hibernate SQL方言 (hibernate.dialect) 数据库 hibernate方言 DB2 org.hibernate.dialect.DB2Dialect DB2 AS/400 org.hibernate.dialect.DB2400Dialect DB2 OS390 org.hibernate.dialect.DB2390Dialect

&#39;hibernate.dialect&#39; must be set when no Connection avalable’

一个错误'hibernate.dialect' must be set when no Connection avalable ‘ 网上也有不少人遇到这种问题,看上去好像是跟Hibernate的方言有关.所以就一直也把焦点放在方言上去寻找解决方案.可是不管怎样都还是报同一个错误. 如果再仔细琢磨一下这句话 'hibernate.dialect' must be set when no Connection avalable 当连接不可用时,必须要设置Hibernate方言 发现问题了!并不是方言

异常:org.hibernate.HibernateException: &#39;hibernate.dialect&#39; must be set when no Connection available

spring整合hibernate报了这样一个异常,一直以为是dialect参数的问题,最后发现原来是配数据源时,数据库的名字写错了....... 找了半天,重新写了配置文件没出问题,但就不知道这个文件哪里出问题了.配置文件里面这种细节一定要注意. 版权声明:本文为博主原创文章,未经博主允许不得转载. 异常:org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available

org.hibernate.MappingException: No Dialect mapping for JDBC type: -4

Stacktraces org.hibernate.MappingException: No Dialect mapping for JDBC type: -4 org.hibernate.dialect.TypeNames.get(TypeNames.java:56) org.hibernate.dialect.TypeNames.get(TypeNames.java:81) org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.