zoukankan      html  css  js  c++  java
  • 2019省赛训练组队赛4.236周二-第九届2012

    A - Taxi Fare

    Last September, Hangzhou raised the taxi fares.

    The original flag-down fare in Hangzhou was 10 yuan, plusing 2 yuan per kilometer after the first 3km and 3 yuan per kilometer after 10km. The waiting fee was 2 yuan per five minutes. Passengers need to pay extra 1 yuan as the fuel surcharge.

    According to new prices, the flag-down fare is 11 yuan, while passengers pay 2.5 yuan per kilometer after the first 3 kilometers, and 3.75 yuan per kilometer after 10km. The waiting fee is 2.5 yuan per four minutes.

    The actual fare is rounded to the nearest yuan, and halfway cases are rounded up. How much more money does it cost to take a taxi if the distance is d kilometers and the waiting time is t minutes.

    Input

    There are multiple test cases. The first line of input is an integer T ≈ 10000 indicating the number of test cases.

    Each test case contains two integers 1 ≤ d ≤ 1000 and 0 ≤ t ≤ 300.

    <h4< dd="">Output

    For each test case, output the answer as an integer.

    Sample Input

    4
    2 0
    5 2
    7 3
    11 4
    

    Sample Output

    0
    1
    3
    5

    代码:

    #include <bits/stdc++.h>
    using namespace std;
    
    int T;
    double d, t;
    
    int main() {
        scanf("%d", &T);
        while(T --) {
            scanf("%lf%lf", &d, &t);
            double mon1 = 0.0, mon2 = 0.0;
            if(d <= 3) {
                mon1 = 10 + 1 + 2 * t / 5;
                mon2 = 11 + 2.5 * t / 4;
            } else if(d > 3 && d <= 10) {
                mon1 = 10 + 1 + 2 * t / 5 + (d - 3) * 2;
                mon2 = 11 + 2.5 * t / 4 + (d - 3) * 2.5;
            } else {
                mon1 = 10 + 1 + 2 * t / 5 + 7 * 2 + (d - 10) * 3;
                mon2 = 11 + 2.5 * t / 4  + 7 * 2.5 + (d - 10) * 3.75;
            }
            printf("%d
    ", (int)(mon2 + 0.5) - (int)(mon1 + 0.5));
        }
        return 0;
    }
    View Code

    D - Draw Something Cheat

    Have you played Draw Something? It's currently one of the hottest social drawing games on Apple iOS and Android Devices! In this game, you and your friend play in turn. You need to pick a word and draw a picture for this word. Then your friend will be asked what the word is, given the picture you have drawn. The following figure illustrates a typical scenario in guessing the word.

    word guessing in draw something

    As you see, when guessing a word you will be given the picture and 12 letters. You must pick some of these letters to form a word that matches the picture. Each letter can only be used once. It is a lot of fun if your friend is a talented painter, but unfortunately some drawings from your friend are totally incomprehensible. After several times of becoming mad by the drawings, you find a way to cheat in the game.

    In this game, letters not included in the correct answer are randomly generated. If you cannot find the correct answer when guessing, you can write down all the letters and restart the game. Then you would find some of these letters are changed. Of course these changed letters will never appear in the answer. By eliminating these letters you are a step closer to the answer.

    So In this problem, you need to write a program to automate the cheating process. Given N strings of letters to the same picture, you need to eliminate as many letters as possible, and output the remaining letters.

    Input

    There are multiple test cases. The first line of the input is an integer T ≈ 1000 indicating the number of test cases.

    Each test case begins with a positive integer N ≤ 20 indicating the number of times you have entered the game. Then N lines follow. Each line is a string of exactly 12 uppercase letters, indicating the candidate letters in one guess. It is guaranteed that the answer has at least 1 letter and has no more than 12 letters.

    Output

    For each test case, output the remaining letters in alphabet order after the process described above. One line for each test case.

    Sample Input

    2
    2
    ABCDEFGHIJKL
    ABCDEFGHIJKL
    2
    SAWBCVUXDTPN
    ZQTLFJYRCGAK
    

    Sample Output

    ABCDEFGHIJKL
    ACT

    代码:

    #include <bits/stdc++.h>
    using namespace std;
    
    int T, N;
    map<char, int> mp, vis;
    
    int main() {
        scanf("%d", &T);
        while(T --) {
            mp.clear();
            scanf("%d", &N);
            string s, t;
            cin >> t;
            for(int i = 0; t[i]; i ++)
                mp[t[i]] ++;
    
            for(int i = 1; i < N; i ++) {
                cin >> s;
                vis.clear();
                for(int j = 0; s[j]; j ++)
                    vis[s[j]] ++;
    
                for(int i = 0; i < 26; i ++)
                    mp[i + 'A'] = min(mp[i + 'A'], vis[i + 'A']);
    
            }
    
            string ans = "";
            for(int i = 0; i < 26; i ++) {
                if(!mp[i + 'A']) continue;
                else {
                    for(int j = 0; j < mp[i + 'A']; j ++)
                        ans += 'A' + i;
                }
            }
    
            cout << ans << endl;
        }
        return 0;
    }
    View Code

    H - Lazier Salesgirl

    Kochiya Sanae is a lazy girl who makes and sells bread. She is an expert at bread making and selling. She can sell the i-th customer a piece of bread for price pi. But she is so lazy that she will fall asleep if no customer comes to buy bread for more than w minutes. When she is sleeping, the customer coming to buy bread will leave immediately. It's known that she starts to sell bread now and the i-th customer come after ti minutes. What is the minimum possible value of w that maximizes the average value of the bread sold?

    Input

    There are multiple test cases. The first line of input is an integer T ≈ 200 indicating the number of test cases.

    The first line of each test case contains an integer 1 ≤ n ≤ 1000 indicating the number of customers. The second line contains n integers 1 ≤ pi ≤ 10000. The third line contains n integers 1 ≤ ti ≤ 100000. The customers are given in the non-decreasing order of ti.

    Output

    For each test cases, output w and the corresponding average value of sold bread, with six decimal digits.

    Sample Input

    2
    4
    1 2 3 4
    1 3 6 10
    4
    4 3 2 1
    1 3 6 10
    

    Sample Output

    4.000000 2.500000
    1.000000 4.000000

    代码:

    #include <bits/stdc++.h>
    using namespace std;
    
    const int maxn = 1010;
    int T, N;
    int sum[maxn], timm[maxn], Tim[maxn];
    
    struct Node {
        int price;
        int tim;
    }node[maxn];
    
    int main() {
        scanf("%d", &T);
        while(T --) {
            scanf("%d", &N);
            for(int i = 0; i < N; i ++)
                scanf("%d", &node[i].price);
            for(int i = 0; i < N; i ++)
                scanf("%d", &node[i].tim);
    
            for(int i = 0; i < N; i ++) {
                if(i == 0) sum[i] = node[i].price, timm[i] = node[i].tim, Tim[i] = node[i].tim;
                else {
                    sum[i] = sum[i - 1] + node[i].price;
                    timm[i] = max(node[i].tim - node[i - 1].tim, timm[i - 1]), Tim[i] = node[i].tim - node[i - 1].tim;
                }
            }
    
            double maxx = -1, temp = -1;
            for(int i = Tim[0]; i <= timm[N - 1]; i ++) {
                int res = -1;
                for(int j = 0; j < N; j ++) {
                    if(Tim[j] > i) {
                        res = j ;
                        break;
                    }
                }
                if(res == -1) res = N;
                if(1.0 * sum[res - 1]/ res > maxx ) {
                    maxx = 1.0 * sum[res - 1] / res;
                    temp = i;
                }
            }
    
            printf("%.6lf %.6lf
    ", temp, maxx);
    
        }
        return 0;
    }
    View Code

    J - Modular Inverse

    The modular modular multiplicative inverse of an integer a modulo m is an integer xsuch that a-1x (mod m). This is equivalent to ax≡1 (mod m).

    Input

    There are multiple test cases. The first line of input is an integer T ≈ 2000 indicating the number of test cases.

    Each test case contains two integers 0 < a ≤ 1000 and 0 < m ≤ 1000.

    Output

    For each test case, output the smallest positive x. If such x doesn't exist, output "Not Exist".

    Sample Input

    3
    3 11
    4 12
    5 13
    

    Sample Output

    4
    Not Exist
    8

    代码:

    #include<bits/stdc++.h>
    using namespace std;
    bool vis[1005];
    int main()
    {
        int T;
        scanf("%d",&T);
        while(T--)
        {
            int a,m;scanf("%d%d",&a,&m);
            bool flag=0;
            memset(vis,0,sizeof(vis));
            for(int i=1; ;i++)
            {
                if(i*a%m==1%m)
                {
                    printf("%d
    ",i);
                    flag=1;
                    break;
                }
                if(vis[i*a%m]&&i>10000)
                    break;
                vis[i*a%m]=1;
            }
            if(flag==0)
                printf("Not Exist
    ");
        }
        return 0;
    }
    View Code

    K - Yet Another Story of Rock-paper-scissors

    Akihisa and Hideyoshi were lovers. They were sentenced to death by the FFF Inquisition. Ryou, the leader of the FFF Inquisition, promised that the winner of Rock-paper-scissors would be immune from the punishment. Being lovers, Akihisa and Hideyoshi decided to die together with their fists clenched, which indicated rocks in the game. However, at the last moment, Akihisa chose paper and Hideyoshi chose scissors. As a result, Akihisa was punished by the FFF Inquisition and Hideyoshi survived alone.

    When a boy named b and a girl named g are being punished by the FFF Inquisition, they will play Rock-paper-scissors and the winner will survive. If there is a tie, then neither of they will survive. At first, they promise to choose the same gesture x. But actually, the boy wants to win and the girl wants to lose. Of course, neither of them knows that the other one may change his/her gesture. At last, who will survive?

    Input

    There are multiple test cases. The first line of input is an integer T ≈ 1000 indicating the number of test cases.

    Each test case contains three strings -- b g x. All strings consist of letters and their lengths never exceed 20. The gesture x is always one of "rock""paper" and "scissors".

    Output

    If there is a tie, output "Nobody will survive". Otherwise, output "y will survive"where y is the name of the winner.

    Sample Input

    1
    Akihisa Hideyoshi rock
    

    Sample Output

    Hideyoshi will survive

    代码:

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int T;
        scanf("%d",&T);
        while(T--)
        {
            char a[101],b[101],c[101];
            scanf("%s%s%s",&a,&b,&c);
            printf("%s will survive
    ",b);
        }
    }
    View Code

    Happy Birthday

     

  • 相关阅读:
    Anglarjs 工具方法
    AngularJs $scope 里面的$apply 方法和$watch方法
    CentOS 下tomcat安装
    Phonegap Android 项目使用Cordova
    Phonegap 原生控件(Android)与html混合
    Phonegap 通信原理
    Phonegap 开发环境搭建
    Phonegap 通知 Notification
    Phonegap 工作原理
    Angularjs MVC
  • 原文地址:https://www.cnblogs.com/zlrrrr/p/10758033.html
Copyright © 2011-2022 走看看