2019山东省赛反省

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

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



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

时间: 2024-11-08 19:17:49

2019山东省赛反省的相关文章

2019山东省赛B - Flipping Game ZOJ - 4114 题解

题意: 初始有n个灯泡,灯泡状态是0和1,.现在有k轮操作,每次改变且仅改变m个的灯的状态,给定n盏灯的初始状态的最终状态,求有多少种解决改变灯的方案满足可以满足题目条件. 思路: 开始写的时候以为是组合计数和容斥原理什么鬼的,后来发现n,m,k的值都比较小,觉得应该是三维dp了,当然是瞎想,最后看题解还是一个二维dp可以解决的问题,只不过是三重循环.给队友lrr说了一下题解的状态定义,他也较快就写出来了.其实对于灯的状态,每次改变一次之后,现在的问题和之前的问题形式一样,只是k值和目标灯的状态

2019山东省赛K - Happy Equation ZOJ - 4123 题解

题意: 一个数论题,要求满足如下等式的x有多少个. 思路: 当时比赛是,队伍看到这个题,也没有做太多的思考,就是无从下手,几乎放弃.但是看到学校另外两支队伍都过了这个题,感觉自己还是好菜. 打表可以发现,当a为奇数的时候答案为1.当a为偶数的时候,x一定也是偶数,这个还是比较明显的. 对左边进行推导,因为a为偶数,设a=2*t,所以a^x=2^x*t^x,所以当x大于p时,这个求余之后一定为0.由于p很小,可以直接暴力求解,所以对于右边直接考虑x^a求余之后为0的x的情况.由于x为偶数.我们再次

山东省赛题 NEU OJ 1444 线段树双标记

http://acm.neu.edu.cn/hustoj/problem.php?id=1444 OJ问题论坛发帖http://t.cn/zjBp4jd FAQ http://t.cn/zjHKbmN Linux问题看http://t.cn/aWnP1n 1444: Devour Magic 时间限制: 1 Sec  内存限制: 256 MB 提交: 129  解决: 21 [提交][状态][讨论版] 题目描述 In Warcraft III, Destroyer is a large flyi

第五届山东省赛总结

这次比赛在HITWH,10号我们早早的坐车来到了威海,然后随便逛了逛,吃了饭,就是热身赛. 热身赛题目比较坑爹,尤其是A题,要求区间素数个数,给的数据是10^7,我写了一个却WA了.后来得知有10^9的情况,感觉一下成了神题,我想了好久也没思路,结束后得知大于10^7的数全部当成10^7做,太坑.但这样都有人能AC,真是膜拜.B题是要交一个随机数,RP比较好,2A.C据说是概率DP,我不会也没仔细看. 之后是开幕式,完了以后我一个人回了宾馆,跟山大威海的同学吃了一顿,随后回去看了看电视就睡了.

hdu1212 Big Number &amp;第六届山东省赛Single Round Math (同余定理,大数取模)

题目链接:Big Number 题目大意:每次输入两个数,第一个是高精度,第二个数小于100000:求 a mod b 根据同余定理: (a+b)% c = (a%c+ b%c)%c (a*b)%c =  ( a%c* b%c)%c 所以 对于大数,例如 :123 可以这样分解 123 =  (1*10+2)*10 + 3: 123 % c =   (  (  (  1%c *  10%c)%c + 2%c) %c  * 10%c) + 3 %c  ) %c; 因此,我们用字符串处理这个数,通过

2019模拟赛09场解题报告

目录 2019模拟赛09场解题报告 目录la~~ 题一:瞬间移动 题二:食物订购 题三:马蹄印 题四:景观美化 2019模拟赛09场解题报告 标签(空格分隔): 解题报告 Forever_chen 2019.8.20 目录la~~ 题一:瞬间移动 [题面] 有一天,暮光闪闪突然对如何将一个整数序列a1,a2,...,an排序为一个不下降序列起了兴趣.身为一只年轻独角兽的她,只能进行一种叫做"单元转换"(unit shift)的操作.换句话说,她可以将序列的最后一个元素移动到它的起始位置

HDU6706 CCPC 2019网络赛 huntian oy 推式子+杜教筛

CCPC 2019 网络赛 HDU 6706 huntian oy 标签 奇奇怪怪的数论结论 杜教筛 前言 我的csdn和博客园是同步的,欢迎来访danzh-博客园~ 简明题意 给定n,a,b,求: \[\sum_{i=1}^n\sum_{j=1}^igcd(i^a-j^a,i^b-j^b)[gcd(i,j)=1]\%(10^9+7)\] 思路 首先有一个结论: \[gcd(i^a-j^a,i^b-j^b)=i^{gcd(a,b)}-j^{gcd(a,b)}\] 上面的结论对于i,j互质是成立的

2019年山东省赛记录

随随便便写的东西... 5月10号开开心心坐上高铁去济南啦,第一次坐济南青岛的高铁,体验还是很舒服的,以后回家就坐这个啦.到了之后有点聊城的感觉,有点想家.打车去了济南大学,吐槽一句,订得这宾馆真垃圾.所以下周去南京的时候订的连锁酒店.晚上去济南大学遛弯儿,舒适. 11号,上午去报道,下午开幕式+热身赛.开幕式的时候山大被讽刺得好惨,今年的冠军??会是哪个学校呢,哈哈哈??.热身赛卡在了C题,二分正确性没有证明,不过 ycz 最后一分钟A了,优秀.除了防AK题都A了. 12号正式赛开始啦.一开始

第6届山东省赛总结帖

又是一年省赛时.在这次省赛之前,窝们队刚经历了换队友风波,这次终于有了一个稳定,积极,一起为共同的目标而努力的队伍.在以很快的速度换完队友之后,距省赛还有不到两个月了.于是每周四在CF的gym上自加一场练习赛,然后加上周末的周赛,每周双赛,跟新队友ly之间的配合也越来越好.我总算把剩下的不算很难的图论知识点都刷完了,+cai也刷了一大堆数据结构,ly也刷了很多数学.(于是计算几何仍然没人刷..). 这次能拿到第4名金牌的成绩,窝们自己在赛前根本没想到会拿到这个成绩.之前的目标就是金牌,根据我们了