zoukankan      html  css  js  c++  java
  • CodeForces Round #185 (Div. 2)A,B,C

    水平稀,只能做A,B,C

    A. Whose sentence is it?
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    One day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said by Freda, and which were said by Rainbow. According to his experience, he thought that Freda always said "lala." at the end of her sentences, while Rainbow always said "miao." at the beginning of his sentences. For each sentence in the chat record, help liouzhou_101 find whose sentence it is.

    Input

    The first line of the input contains an integer n (1≤n≤10), number of sentences in the chat record. Each of the next n lines contains a sentence. A sentence is a string that contains only Latin letters (A-Za-z), underline (_), comma (,), point (.) and space ( ). Its length doesn’t exceed 100.

    Output

    For each sentence, output "Freda's" if the sentence was said by Freda, "Rainbow's" if the sentence was said by Rainbow, or "OMG>.< I don't know!" if liouzhou_101 can’t recognize whose sentence it is. He can’t recognize a sentence if it begins with "miao." and ends with "lala.", or satisfies neither of the conditions.

    Sample test(s)
    input
    5
    I will go to play with you lala.
    wow, welcome.
    miao.lala.
    miao.
    miao .
    output
    Freda's
    OMG>.< I don't know!
    OMG>.< I don't know!
    Rainbow's
    OMG>.< I don't know!

    #include <iostream>
    #include <cstring>
    #include <cstdio>

    using namespace std;

    int main()
    {
        int T;
        cin>>T;
        getchar();
    while(T--)
    {
        char str[111];
        gets(str);
        int F=0,R=0;
        int len=strlen(str);

     //   for(int i=0;i<len;i++)
     //       cout<<i<<":"<<str<<" ";
     //   cout<<endl;

        if(str[0]=='m'&&str[1]=='i'&&str[2]=='a'&&str[3]=='o'&&str[4]=='.')
            R=1;
        if(str[len-1]=='.'&&str[len-2]=='a'&&str[len-3]=='l'&&str[len-4]=='a'&&str[len-5]=='l')
            F=1;
     //   cout<<R<<",,,,"<<F<<endl;
        if(F==1&&R==0)
            cout<<"Freda's"<<endl;
        else if(R==1&&F==0)
            cout<<"Rainbow's"<<endl;
        else
            cout<<"OMG>.< I don't know!"<<endl;

    }
        return 0;
    }


    B. Archer
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    SmallR is an archer. SmallR is taking a match of archer with Zanoes. They try to shoot in the target in turns, and SmallR shoots first. The probability of shooting the target each time is CodeForces Round 185 (Div. 2)A,B,C - qhn999 - 码代码的猿猿 for SmallR while CodeForces Round 185 (Div. 2)A,B,C - qhn999 - 码代码的猿猿 for Zanoes. The one who shoots in the target first should be the winner.

    Output the probability that SmallR will win the match.

    Input

    A single line contains four integers CodeForces Round 185 (Div. 2)A,B,C - qhn999 - 码代码的猿猿.

    Output

    Print a single real number, the probability that SmallR will win the match.

    The answer will be considered correct if the absolute or relative error doesn't exceed 10-6.

    Sample test(s)
    input
    1 2 1 2
    output
    0.666666666667


    #include <iostream>
    #include <cstdio>

    using namespace std;

    int main()
    {
        double a,b,c,d;
        cin>>a>>b>>c>>d;

        double p1=a/b;
        double p2=c/d;

        double Q=(1-p1)*(1-p2);

        int T=30;
        double sum=p1*(1/(1-Q));

        printf("%.10lf\n",sum);

        return 0;
    }
     

    C. The Closest Pair
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.

    The problem is the follows. Given n points in the plane, find a pair of points between which the distance is minimized. Distance between (x1,y1) and (x2,y2) is CodeForces Round 185 (Div. 2)A,B,C - qhn999 - 码代码的猿猿.

    The pseudo code of the unexpected code is as follows:


    input n
    for i from 1 to n
    input the i-th point's coordinates into p
    sort array p[] by increasing of x coordinate first and increasing of y coordinate second
    d=INF //here INF is a number big enough
    tot=0
    for i from 1 to n
    for j from (i+1) to n
    ++tot
    if (p[j].x-p.x>=d) then break //notice that "break" is only to be
    //out of the loop "for j"
    d=min(d,distance(p,p[j]))
    output d

    Here, tot can be regarded as the running time of the code. Due to the fact that a computer can only run a limited number of operations per second, tot should not be more than k in order not to get Time Limit Exceeded.

    You are a great hacker. Would you please help Tiny generate a test data and let the code get Time Limit Exceeded?

    Input

    A single line which contains two space-separated integers n and k (2≤n≤20001≤k≤109).

    Output

    If there doesn't exist such a data which let the given code get TLE, print "no solution" (without quotes); else print n lines, and the i-th line contains two integers xi,yi (|xi|,|yi|≤109)representing the coordinates of the i-th point.

    The conditions below must be held:

    • All the points must be distinct.
    • |xi|,|yi|≤109.
    • After running the given code, the value of tot should be larger than k.

    Sample test(s)
    input
    4 3
    output
    0 0
    0 1
    1 0
    1 1
    input
    2 100
    output
    no solution
     
     
    #include <iostream>
    #include <cmath>
    #include <cstdio>

    using namespace std;

    int main()
    {
        int n;unsigned long long int k;
        cin>>n>>k;
        unsigned long long int tot=0;
        for(int i=1;i<=n;i++)
            for(int j=i+1;j<=n;j++)
              tot++;
        if(tot<=k)  cout<<"no solution"<<endl;
        else
        {
            for(int i=1;i<=n;i++)
                printf("0 %d\n",i);
        }

        return 0;
    }
  • 相关阅读:
    LeetCode 566 重塑矩阵
    LeetCode 283 移动零
    C++Template(类模板二)
    Qt之简单绘图实现
    QT控件之QSlider
    Redis
    布局总结三: icon图标+标题上下两排排列
    vue中在data中引入图片的路径方法
    布局总结二:宽高比固定比例---移动端
    在vue中使用vue-awesome-swiper插件
  • 原文地址:https://www.cnblogs.com/CKboss/p/3351055.html
Copyright © 2011-2022 走看看