zoukankan      html  css  js  c++  java
  • 2019省赛训练组队赛4.11周四 2014浙江省赛

    A - Pokemon Master

    Calem and Serena are pokemon masters. One day they decided to have a pokemon battle practice before Pokemon World Championships. Each of them has some pokemons in each's team. To make the battle more interesting, they decided to use a special rule to determine the winner: the team with heavier total weight will win the battle!

    Input

    There are multiple test cases. The first line of input contains an integer Tindicating the number of test cases. For each test case:

    The first line contains two integers N and M (1 <= NM <= 6), which describes that Calem has N pokemons and Serena has M pokemons.

    The second line contains N integers indicating the weight of Calem's pokemons. The third line contains M integers indicating the weight of Serena's pokemons. All pokemons' weight are in the range of [1, 2094] pounds.

    <h4< dd="">Output

    For each test case, output "Calem" if Calem's team will win the battle, or "Serena" if Serena's team will win. If the two team have the same total weight, output "Draw" instead.

    <h4< dd="">Sample Input

    1
    6 6
    13 220 199 188 269 1014
    101 176 130 220 881 396
    代码:
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int T;
        scanf("%d",&T);
        while(T--)
        {
            int n,m;
            scanf("%d%d",&n,&m);
            int sum1=0,sum2=0;
            for(int i=1;i<=n;i++)
            {
                int x;
                scanf("%d",&x);
                sum1+=x;
            }
            for(int i=1;i<=m;i++)
            {
                int x;
                scanf("%d",&x);
                sum2+=x;
            }
            if(sum1==sum2) printf("Draw
    ");
            else if(sum1>sum2) printf("Calem
    ");
            else if(sum2>sum1) printf("Serena
    ");
        }
        
        
        return 0;
    }
    View Code

    C - Talented Chef

    As we all know, Coach Gao is a talented chef, because he is able to cook M dishes in the same time. Tonight he is going to have a hearty dinner with his girlfriend at his home. Of course, Coach Gao is going to cook all dishes himself, in order to show off his genius cooking skill to his girlfriend.

    To make full use of his genius in cooking, Coach Gao decides to prepare N dishes for the dinner. The i-th dish contains Ai steps. The steps of a dish should be finished sequentially. In each minute of the cooking, Coach Gao can choose at most Mdifferent dishes and finish one step for each dish chosen.

    Coach Gao wants to know the least time he needs to prepare the dinner.

    Input

    There are multiple test cases. The first line of input contains an integer Tindicating the number of test cases. For each test case:

    The first line contains two integers N and M (1 <= NM <= 40000). The second line contains N integers Ai (1 <= Ai <= 40000).

    <h4< dd="">Output

    For each test case, output the least time (in minute) to finish all dishes.

    <h4< dd="">Sample Input

    2
    3 2
    2 2 2
    10 6
    1 2 3 4 5 6 7 8 9 10
    

    <h4< dd="">Sample Output

    3
    10

    代码:

    #include <bits/stdc++.h>
    #define ll long long
    using namespace std;
    int main()
    {
        int T;
        scanf("%d",&T);
        while(T--)
        {
            int n,m;
            scanf("%d%d",&n,&m);
            int maxx=0;
            ll sum=0;
            for(int i=1;i<=n;i++)
            {
                int x;
                scanf("%d",&x);
                maxx=max(maxx,x);
                sum+=x;
            }
            ll ans=sum/m;
            if(sum%m) ans++;
            ans=max(ans,1LL*maxx);
            cout<<ans<<endl;
        }
        return 0;
    }
    View Code

    G - Ternary Calculation

    Complete the ternary calculation.

    Input

    There are multiple test cases. The first line of input contains an integer Tindicating the number of test cases. For each test case:

    There is a string in the form of "number1 operatora number2 operatorb number3". Each operator will be one of {'+', '-' , '*', '/', '%'}, and each number will be an integer in [1, 1000].

    <h4< dd="">Output

    For each test case, output the answer.

    <h4< dd="">Sample Input

    5
    1 + 2 * 3
    1 - 8 / 3
    1 + 2 - 3
    7 * 8 / 5
    5 - 8 % 3
    

    <h4< dd="">Sample Output

    7
    -1
    0
    11
    3
    

    Note

    The calculation "A % B" means taking the remainder of A divided by B, and "A / B" means taking the quotient.

    代码:

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int T;
        scanf("%d",&T);
        while(T--)
        {
            char op1,op2;
            int a,b,c;
            int ans;
            cin>>a>>op1>>b>>op2>>c;
            if(op1=='+')
            {
                if(op2=='+') ans=a+b+c;
                if(op2=='-') ans=a+b-c;
                if(op2=='*') ans=a+b*c;
                if(op2=='/') ans=a+b/c;
                if(op2=='%') ans=a+b%c;
            }
            if(op1=='-')
            {
                if(op2=='+') ans=a-b+c;
                if(op2=='-') ans=a-b-c;
                if(op2=='*') ans=a-b*c;
                if(op2=='/') ans=a-b/c;
                if(op2=='%') ans=a-b%c;
            }
            if(op1=='*')
            {
                if(op2=='+') ans=a*b+c;
                if(op2=='-') ans=a*b-c;
                if(op2=='*') ans=a*b*c;
                if(op2=='/') ans=a*b/c;
                if(op2=='%') ans=a*b%c;
            }
            if(op1=='/')
            {
                if(op2=='+') ans=a/b+c;
                if(op2=='-') ans=a/b-c;
                if(op2=='*') ans=a/b*c;
                if(op2=='/') ans=a/b/c;
                if(op2=='%') ans=a/b%c;
            }
            if(op1=='%')
            {
                if(op2=='+') ans=a%b+c;
                if(op2=='-') ans=a%b-c;
                if(op2=='*') ans=a%b*c;
                if(op2=='/') ans=a%b/c;
                if(op2=='%') ans=a%b%c;
            }
            cout<<ans<<endl;
            
        }
    
        return  0;
    }
    View Code

    J - What day is that day?

    It's Saturday today, what day is it after 11 + 22 + 33 + ... + NN days?

    Input

    There are multiple test cases. The first line of input contains an integer Tindicating the number of test cases. For each test case:

    There is only one line containing one integer N (1 <= N <= 1000000000).

    <h4< dd="">Output

    For each test case, output one string indicating the day of week.

    <h4< dd="">Sample Input

    2
    1
    2
    

    <h4< dd="">Sample Output

    Sunday
    Thursday
    

    <h4< dd="">Hint

    A week consists of Sunday, Monday, Tuesday, Wednesday, Thursday, Friday and Saturday.

    代码:

    #include<bits/stdc++.h>
    using namespace std;
    int p[22][22][2];
    char t[8][22]={"Sunday" , "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
    int cal(int n)
    {
        int ans=0;
        for(int i=1;i<=6;i++)
        {
            if(i>n) break;
            int N=(n-i)/7;
            int a1=p[i][i][0],q=p[i][7][0],qn=p[q][(N+1)%6][0];
            int tmp;
            if(q==1)
                tmp=N*a1+a1;
            else
                tmp=a1*(qn-1)*p[q-1][5][0]%7;
            ans+=tmp+7;
            ans%=7;
        }
        return ans;
    }
    
    int main()
    {
    
        for(int i=0;i<10;i++)
        {
            p[i][0][0]=p[i][0][1]=1;
            for(int j=1;j<10;j++)
            {
                p[i][j][0]=p[i][j-1][0]*i%7;
                p[i][j][1]=p[i][j-1][1]*i%5;
            }
        }
       //cout<<cal(1)<<endl;
        int T;scanf("%d",&T);
        while(T--)
        {
            int n;scanf("%d",&n);
            n=(cal(n)+6)%7;
            printf("%s
    ",t[n]);
        }
    }
    View Code
    #include <bits/stdc++.h>
    using namespace std;
    
    int T;
    char Day[10][10]={"Saturday","Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday"};
    int all[550];
    
    long long Pow(int a, int b) {
        long long ans = 1;
        while(b) {
            if(b % 2) {
                ans = (ans % 7) * (a % 7);
                b --;
            } else {
                a = (a % 7) * (a % 7);
                b /= 2;
            }
        }
        return ans % 7;
    }
    
    int main() {
        all[0] = 0;
        for(int i = 1; i <= 294; i ++)
            all[i] = (all[i - 1] + Pow(i, i)) % 7;
    
        scanf("%d", &T);
        while(T --) {
            long long N;
            scanf("%lld", &N);
            N %= 294;
            printf("%s
    ", Day[all[N]]);
        }
        return 0;
    }
    找规律的 code

    这个训练的时候想着打表但是没打完 快速幂的时候忘记取模了 一会重写一个贴一下 打表找规律

    1 4 6 4 3 1 0 1 1 4 2 1 6 0 1 2 5 1 5 1 0 1 4 1 4 4 6 0 1 1 3 2 6 1 0 1 2 2 1 2 6 0 ($N^N$ % 7 的规律)

    L - Access System

    For security issues, Marjar University has an access control system for each dormitory building.The system requires the students to use their personal identification cards to open the gate if they want to enter the building.

    The gate will then remain unlocked for L seconds. For example L = 15, if a student came to the dormitory at 17:00:00 (in the format of HH:MM:SS) and used his card to open the gate. Any other students who come to the dormitory between [17:00:00, 17:00:15) can enter the building without authentication. If there is another student comes to the dorm at 17:00:15 or later, he must take out his card to unlock the gate again.

    There are N students need to enter the dormitory. You are given the time they come to the gate. These lazy students will not use their cards unless necessary. Please find out the students who need to do so.

    Input

    There are multiple test cases. The first line of input contains an integer Tindicating the number of test cases. For each test case:

    The first line contains two integers N (1 <= N <= 20000) and L (1 <= L <= 3600). The next N lines, each line is a unique time between [00:00:00, 24:00:00) on the same day.

    <h4< dd="">Output

    For each test case, output two lines. The first line is the number of students who need to use the card to open the gate. The second line the the index (1-based) of these students in ascending order, separated by a space.

    <h4< dd="">Sample Input

    3
    2 1
    12:30:00
    12:30:01
    5 15
    17:00:00
    17:00:15
    17:00:06
    17:01:00
    17:00:14
    3 5
    12:00:09
    12:00:05
    12:00:00
    

    <h4< dd="">Sample Output

    2
    1 2
    3
    1 2 4
    2
    2 3

    代码:

    #include <bits/stdc++.h>
    using namespace std;
    
    const int maxn = 1e6 + 10;
    int T;
    
    struct Node{
        int tim;
        int id;
    }node[maxn];
    
    bool cmp(const Node &a, const Node &b) {
        return a.tim < b.tim;
    }
    
    int main() {
        scanf("%d", &T);
        while(T --) {
            int N, L;
            scanf("%d%d", &N, &L);
            for(int i = 1; i <= N; i ++) {
                int h, m, s;
                scanf("%d:%d:%d", &h, &m, &s);
                int sum = h * 3600 + m * 60 + s;
                node[i].tim = sum;
                node[i].id = i;
            }
            sort(node + 1, node + 1 + N, cmp);
            vector<int> ans;
            int now = node[1].tim;
            ans.push_back(node[1].id);
            for(int i = 2; i <= N; i ++) {
                if(node[i].tim < now + L) continue;
                else {
                    ans.push_back(node[i].id);
                    now = node[i].tim;
                }
            }
            sort(ans.begin(), ans.end());
            printf("%d
    ", ans.size());
            for(int i = 0; i < ans.size(); i ++)
            printf("%d%s", ans[i], i != ans.size() - 1 ? " " : "
    ");
        }
        return 0;
    }
    View Code

    EF 是搜索 但是没想好怎么写!我会记得清题的

  • 相关阅读:
    JCreator的配置
    哈夫曼编码
    最小生成树
    逻辑左移右移与算术左移右移
    原码 反码 补码 移码
    hdu 小希的迷宫
    (二)Qt窗口应用程序Widget
    (一)Qt5模块,QtCreator常用快捷键,命名规范
    if __name__="__main__"
    数据库之sql语句汇总
  • 原文地址:https://www.cnblogs.com/zlrrrr/p/10692406.html
Copyright © 2011-2022 走看看