Yahoo Programming Contest 2019

Posted dup4

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Yahoo Programming Contest 2019相关的知识,希望对你有一定的参考价值。

A - Anti-Adjacency

签.

技术图片
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 int main()
 5 {
 6     int n, k;
 7     while (scanf("%d%d", &n, &k) != EOF)
 8     {
 9         int remind = (n + 1) / 2;
10         puts(k <= remind ? "YES" : "NO");
11     }
12     return 0;
13 }
View Code

 

 

B - Path

签.

技术图片
#include <bits/stdc++.h>
using namespace std;

int x, y, Max;
vector <int> G[5];

void DFS(int u, int fa, int deep)
{
    Max = max(Max, deep);
    for (auto v : G[u]) if (v != fa)
        DFS(v, u, deep + 1);
}

int main()
{
    while (scanf("%d%d", &x, &y) != EOF)
    {
        for (int i = 1; i <= 4; ++i) G[i].clear();
        G[x].push_back(y);
        G[y].push_back(x);
        for (int i = 1; i <= 2; ++i)
        {
            scanf("%d%d", &x, &y);
            G[x].push_back(y);
            G[y].push_back(x);
        }
        Max = 0;
        DFS(1, 1, 1);
        puts(Max == 4 ? "YES" : "NO");
    }
    return 0;
}
View Code

 

 

C - When I hit my pocket...

签.

技术图片
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 #define ll long long
 5 int k, a, b;
 6 
 7 int main()
 8 {
 9     while (scanf("%d%d%d", &k, &a, &b) != EOF)
10     {
11         if (a >= (b - 2) || k < a) printf("%d
", k + 1);
12         else
13         {
14             k -= a - 1;
15             int Loop = k / 2;
16             if (Loop == 0) printf("%d
", a + k % 2);
17             else printf("%lld
", 1ll * b + 1ll * (Loop - 1) * (b - a) + k % 2);
18         }
19     }
20     return 0;
21 }
View Code

 

以上是关于Yahoo Programming Contest 2019的主要内容,如果未能解决你的问题,请参考以下文章

Yahoo Programming Contest 2019 F - Pass

Yahoo Programming Contest 2019 D - Ears

Atcoder Yahoo Programming Contest 2019 简要题解

Yahoo Programming Contest 2019 F - Pass

Yahoo Programming Contest 2019.E.Odd Subrectangles(思路 线性基)

Yahoo Programming Contest 2019 D-Ears