关于一些初级ACM竞赛题目的分析和题解(七)。

                    

关于一些初级ACM竞赛题目的分析和题解(七)

            昨晚和cy1999相约一起打cf,结果晚了一个小时哭进的时候菜都快凉了,幸亏都skip了不然就掉分到newbie了,下面上题:
A. Supermarket
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

We often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked how much the items are, the clerk will say that a yuan for bkilos (You don't need to care about what "yuan" is), the same as a / b yuan for a kilo.

Now imagine you'd like to buy m kilos of apples. You've asked n supermarkets and got the prices. Find the minimum cost for those apples.

You can assume that there are enough apples in all supermarkets.

Input

The first line contains two positive integers n and m (1 ≤ n ≤ 5 0001 ≤ m ≤ 100), denoting that there are n supermarkets and you want to buy m kilos of apples.

The following n lines describe the information of the supermarkets. Each line contains two positive integers a, b (1 ≤ a, b ≤ 100), denoting that in this supermarket, you are supposed to pay a yuan for b kilos of apples.

Output

The only line, denoting the minimum cost for m kilos of apples. Please make sure that the absolute or relative error between your answer and the correct answer won't exceed 10 - 6.

Formally, let your answer be x, and the jury's answer be y. Your answer is considered correct if .

Examples
input
3 5
1 2
3 4
1 3
output
1.66666667
input
2 1
99 100
98 99
output
0.98989899
Note

In the first sample, you are supposed to buy 5 kilos of apples in supermarket 3. The cost is 5 / 3 yuan.

In the second sample, you are supposed to buy 1 kilo of apples in supermarket 2. The cost is 98 / 99yuan.


这道题是输入n,m(n小于5000,m小于100),n表示n家超市,m表示要买m斤,以下n行输入a,b两个数(a,b均小于100) 表示a元b斤  a/b表示单个成本,输出买m斤的最小花费,下面是代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    double c,a,b,d,m;  //  定义含浮点的变量
    cin>>n>>m;  //  输入n,m
    d=1000;  //  先整一个比较大的数
    while(n--)
        {cin>>a>>b;
        c=a/b;
        if(c<=d)d=c;
        }
        printf("%.8lf",d*m);  //  输出小数点后八位的结果

}
若有小数出现,就在定义变量时用double,而输出时根据小数的位数若要8位就printf("%.8lf",a);   %.nlf表示n位小数,


A. Chat room
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word s. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word "hello". For example, if Vasya types the word "ahhellllloou", it will be considered that he said hello, and if he types "hlelo", it will be considered that Vasya got misunderstood and he didn't manage to say hello. Determine whether Vasya managed to say hello by the given word s.

Input

The first and only line contains the word s, which Vasya typed. This word consisits of small Latin letters, its length is no less that 1 and no more than 100 letters.

Output

If Vasya managed to say hello, print "YES", otherwise print "NO".

Examples
input
ahhellllloou
output
YES
input
hlelo
output
NO
这一题是输入一行字符串,若存在顺序hello,则就输出YES,否则输出NO;下面是代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int j,l,c;
    char a[1000],b[5];  // 定义字符串
    b[0]='h';  //  字符串赋值
    b[1]='e';
    b[2]='l';
    b[3]='l';
    b[4]='o';
    gets (a);  //  输入字符串
    j=0;
    l=strlen(a);  //  找到字符串长度
    for (int i=0;i<=l-1;i++)
        {if (a[i]==b[j])
            j++;  //  计数

            if(j==5)
                return 0*printf("YES");
                }
    if(j!=5) printf("NO");  //输出

}
注意定义字符串时,如b[5]表示可容纳五个字符,即读不到b[5],辣鸡monster_ayb定义的是b[4]结果老是出错,多亏cy1999巨巨指出才发现,感谢cy1999害羞










ACM/ICPC(ACM International Collegiate Programming Contest, 国际大学生程序设计竞赛)是由国际计算机界历史悠久、颇具权威性的组织ACM(Association for Computing Machinery,国际计算机协会)主办的,世界上公认的规模最大、水平最高的国际大学生程序设计竞赛,其目的旨在使大学生运用计算机来充分展示自己分析问题和解决问题的能力。该项竞赛从1970年举办至今已历29届,一直受到国际各知名大学的重视,并受到全世界各著名计算机公司的高度关注,在过去十几年中,APPLE、AT&T、MICROSOFT和IBM等世界著名信息企业分别担任了竞赛的赞助商。可以说,ACM国际大学生程序设计竞赛已成为世界各国大学生最具影响力的国际级计算机类的赛事,是广大爱好计算机编程的大学生展示才华的舞台,是著名大学计算机教育成果的直接体现,是信息企业与世界顶尖计算机人才对话的最好机会。   该项竞赛分区域预赛和国际决赛两个阶段进行,各预赛区第一名自动获得参加世界决赛的资格,世界决赛安排在每年的3~4月举行,而区域预赛安排在上一年的9~12月在各大洲举行。   ACM/ICPC的区域预赛是规模很大、范围很广的赛事。仅在2003年参加区域预赛的队伍就有来自75个国家(地区),1411所大学的3150支代表队,他们分别在127个赛场中进行比赛,以争夺全球总决赛的73个名额,其激烈程度可想而知。 2005年第30届ACM/ICPC亚洲赛区预赛共设了北京、成都、汉城、东京等11个赛站,来自亚洲各国知名高校的各个代表队进行了激烈的角逐。
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值