码迷,mamicode.com
首页 > 其他好文 > 详细

2019山东省赛反省

时间:2019-05-14 19:01:29      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:nta   --   nap   oop   pts   har   color   res   需要   

此次比赛,我很荣幸得此机会跟着学长学姐去打铁。第一次接触这种比赛,确实感到新奇,同时也有不安,因为平时没好好做题,知之甚少,基础确实是超级不稳的。好在学长说让我们开阔一下眼界,尽力就行。比赛做出几个题我就不说了,但是补题的时候真的发现我们真的很菜,简单的题我们竟然可以耗时那么久。。。。。emmm,,以后可得努力了

A - Calandar

On a planet far away from Earth, one year is composed of 12 months, and each month always consists of 30 days.

Also on that planet, there are 5 days in a week, which are Monday, Tuesday, Wednesday, Thursday and Friday. That is to say, if today is Monday, then tomorrow will be Tuesday, the day after tomorrow will be Wednesday. After 3 days it will be Thursday, after 4 days it will be Friday, and after 5 days it will again be Monday.

Today is the -th day in the -th month of year . Given the day of today on that planet, what day will it be (or was it) on the -th day in the -th month of year on that planet?

Input

There are multiple test cases. The first line of the input contains an integer (about 100), indicating the number of test cases. For each test case:

The first line contains three integers , , (, , ) and a string , indicating the date and day of today on that planet. It‘s guaranteed that is either "Monday", "Tuesday", "Wednesday", "Thursday" or "Friday".

The second line contains three integers , and (, , ), indicating the date whose day we want to know.

<h4< dd="">Output

For each test case output one line containing one string, indicating the day of the -th day in the -th month of year on that planet.

<h4< dd="">Sample Input

4
2019 5 12 Monday
2019 5 14
2019 5 12 Tuesday
2019 12 30
2019 5 12 Friday
1000000000 1 1
1000000000 1 1 Wednesday
2019 5 12

<h4< dd="">Sample Output

Wednesday
Friday
Thursday
Thursday
题解:这道水题其实超简单,一个月30天,一个周5天,压根不用管年和月,直接算天数就??啦
#include<iostream>
#include<cstring>
using namespace std;
int t,y1,y2,m1,m2,d1,d2,sum=0;
char s[6][20]={"Monday","Tuesday","Wednesday","Thursday","Friday"};
int main()
{
    cin>>t;
    char a[20];
    while(t--)
    {
        cin>>y1>>m1>>d1>>a;
        cin>>y2>>m2>>d2;
        if(d1<=d2)
        {
            sum=(d2-d1)%5;
            for(int i=0;i<5;i++)
            {
                if(strcmp(a,s[i])==0)
                {
                    cout<<s[(sum+i)%5]<<endl;
                    break;
                }
            }    
        }
        else
        {
            sum=(d2+30-d1)%5;
            for(int i=0;i<5;i++)
            {
                if(strcmp(a,s[i])==0)
                {
                    cout<<s[(sum+i)%5]<<endl;
                    break;
                }
            }    
        }
    }
    return 0;
} 

D - Game on a Graph

There are people playing a game on a connected undirected simple graph with () vertices (numbered from 0 to ) and edges. These people, numbered from 0 to , are divided into two groups and the game goes as follows:

  • They take turns to make the move. That is to say, person number 0 will make the 1st move, person number 1 will make the 2nd move, ..., person number will make the -th move.
  • During a move, the current player MUST select an edge from the current graph and remove it. If the graph is no longer connected after removing the edge, the group this person belongs to loses the game (and of course their opponents win), and the game ends immediately.

 

Given the initial graph when the game starts, if all people use the best strategy to win the game for their groups, which group will win the game?

Recall that a simple graph is a graph with no self loops or multiple edges.

Input

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

The first line contains an integer (), indicating the number of people.

The second line contains a string of length (). indicates that person number belongs to the 1st group, and indicates that person number belongs to the 2nd group.

The third line contains two integers and (, ), indicating the number of vertices and edges of the initial graph.

The following lines each contains two integers and (), indicating that there is an edge connecting vertex and in the initial graph.

It‘s guaranteed that:

  • The initial graph is a connected undirected simple graph.
  • There exist two people who belong to different groups.
  • The sum of , the sum of and the sum of in all test cases will not exceed .

 

<h4< dd="">Output

For each test case output one line containing one integer. If the 1st group wins, output "1" (without quotes); If the 2nd group wins, output "2" (without quotes).

<h4< dd="">Sample Input
3
5
11212
4 6
0 1
0 2
0 3
1 2
1 3
2 3
5
11121
5 7
0 2
1 3
2 4
0 3
1 2
3 2
4 1
3
121
4 3
0 1
0 2
1 3
<h4< dd="">Sample Output
2
1
2

题解:这是一道和博弈论有关的题,仔细分析,然后判断(m-n)%k
#include<iostream>
#include<cstring>
using namespace std;
int t,y1,y2,m1,m2,d1,d2,sum=0;
char s[6][20]={"Monday","Tuesday","Wednesday","Thursday","Friday"};
int main()
{
    cin>>t;
    char a[20];
    while(t--)
    {
        cin>>y1>>m1>>d1>>a;
        cin>>y2>>m2>>d2;
        if(d1<=d2)
        {
            sum=(d2-d1)%5;
            for(int i=0;i<5;i++)
            {
                if(strcmp(a,s[i])==0)
                {
                    cout<<s[(sum+i)%5]<<endl;
                    break;
                }
            }    
        }
        else
        {
            sum=(d2+30-d1)%5;
            for(int i=0;i<5;i++)
            {
                if(strcmp(a,s[i])==0)
                {
                    cout<<s[(sum+i)%5]<<endl;
                    break;
                }
            }    
        }
    }
    return 0;
} 

F - Stones in the Bucket

There are buckets on the ground, where the -th bucket contains stones. Each time one can perform one of the following two operations:

 

  • Remove a stone from one of the non-empty buckets.
  • Move a stone from one of the buckets (must be non-empty) to any other bucket (can be empty).

 

 

 

What‘s the minimum number of times one needs to perform the operations to make all the buckets contain the same number of stones?

Input

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

 

The first line contains an integer (), indicating the number of buckets.

 

The second line contains integers (), indicating the number of stones in the buckets.

 

It‘s guaranteed that the sum of of all test cases will not exceed .

<h4< dd="">Output

For each test case output one line containing one integer, indicating the minimum number of times needed to make all the buckets contain the same number of stones.

<h4< dd="">Sample Input

4
3
1 1 0
4
2 2 2 2
3
0 1 4
1
1000000000

<h4< dd="">Sample Output

2
0
3
0

<h4< dd="">Hint

For the first sample test case, one can remove all the stones in the first two buckets.

 

For the second sample test case, as all the buckets have already contained the same number of stones, no operation is needed.

 

For the third sample test case, one can move 1 stone from the 3rd bucket to the 1st bucket and then remove 2 stones from the 3rd bucket.

题解:这道题思想其实也很简单

  当n=1时,当所给的n个数相等时特判

 其他的时候他就是求所给的数都相等需要移动的石头,我的想法就是算平均值,然后找出比平均值大的那个数,做差即可

#include<iostream>
using namespace std;
const int maxn=1e7;
int a[maxn];
int main()
{
    int t,n,cnt;
    long long sum,ave,num;
    cin>>t;
    while(t--)
    {
        sum=0,num=0,cnt=0;
        cin>>n;
        for(int i=0;i<n;i++)
          cin>>a[i];
        for(int i=0;i<n;i++)
        {
            sum+=a[i];
            ave=sum/n;
        } 
        for(int i=0;i<n;i++)
        {
            if(a[i]>ave)
               num+=(a[i]-ave);
            if(a[i]==a[i+1])
              cnt++;
        }
        if(n!=1||cnt!=n-1)
            cout<<num<<endl;
        else
        {
            cout<<"0"<<endl;
        }
        
    }
    return 0;
}

M - Sekiro

Sekiro: Shadows Die Twice is an action-adventure video game developed by FromSoftware and published by Activision. In the game, the players act as a Sengoku period shinobi known as Wolf as he attempts to take revenge on a samurai clan who attacked him and kidnapped his lord.

技术图片

As a game directed by Hidetaka Miyazaki, Sekiro (unsurprisingly) features a very harsh death punishment. If the player dies when carrying amount of money, the amount of money will be reduced to , where indicates the smallest integer that .

As a noobie of the game, BaoBao has died times in the game continuously. Given that BaoBao carried amount of money before his first death, and that BaoBao didn‘t collect or spend any money during these deaths, what‘s the amount of money left after his deaths?

Input

There are multiple test cases. The first line of the input contains an integer (about ), indicating the number of test cases. For each test case:

The first and only line contains two integers and (, ), indicating the initial amount of money BaoBao carries and the number of times BaoBao dies in the game.

<h4< dd="">Output

For each test case output one line containing one integer, indicating the amount of money left after deaths.

<h4< dd="">Sample Input

4
10 1
7 1
10 2
7 2

<h4< dd="">Sample Output

5
4
3
2

<h4< dd="">Hint

For the third sample test case, when BaoBao dies for the first time, the money he carries will be reduced from 10 to 5; When he dies for the second time, the money he carries will be reduced from 5 to 3.

题解:这道题题意很容易理解,但是怎么写不超时

我用了pow函数就过了,就是一个mod2的过程

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        long long n,k,x;
        cin>>n>>k;
        x=pow(2,k);
        if(n%x==0)
           cout<<n/x<<endl;
        else
           cout<<n/x+1<<endl;
    }
    return 0;
}

先写真么多。。。。补题中

 


2019山东省赛反省

标签:nta   --   nap   oop   pts   har   color   res   需要   

原文地址:https://www.cnblogs.com/ylrwj/p/10863823.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!