AtCoder Yahoo Programming Contest 2019

第一次打AtCoer的比赛,网络卡到爆炸,页面都打不开……体验极差(所以题目也不想补了

A - Anti-Adjacency

Description:

Determine if we can choose K K K different integers between 1 1 1 and N N N (inclusive) so that no two of them differ by 1 1 1 .

Input:

Input is given from Standard Input in the following format:

N N N K K K

  • 1 N , K 100 1≤N,K≤100 1N,K100
  • N N N and K K K are integers.

Output

If we can choose K K K integers as above, print YES; otherwise, print NO.

Sample Input:

3 2

Sample Output:

YES

Sample Input:

5 5

Sample Output:

NO

Sample Input:

31 10

Sample Output:

YES

Sample Input:

10 90

Sample Output:

NO

题目链接

问在 [ 1 , n ] [1,n] [1,n] 内能否拿出不连续的 k k k 个数

[ 1 , n ] [1,n] [1,n] 内最多可取的不连续数字数量为 n 2 \lceil \frac{n}{2} \rceil 2n ,所以直接和 k k k 比较判断即可

AC代码:

#include <bits/stdc++.h>
using namespace std;

int N, K;

int main(int argc, char *argv[]) {
    scanf("%d%d", &N, &K);
    if (N >= 2 * K - 1) printf("YES\n");
    else printf("NO\n");
    return 0;
}

B - Path

Description:

There are four towns, numbered 1 , 2 , 3 1,2,3 1,2,3 and 4 4 4 . Also, there are three roads. The ii-th road connects different towns a i ai ai and b i bi bi bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads.

Determine if we can visit all the towns by traversing each of the roads exactly once.

Input:

Input is given from Standard Input in the following format:

a 1 a_1 a1 b 1 b_1 b1
a 2 a_2 a2 b 2 b_2 b2
a 3 a_3 a3 b 3 b_3 b3

  • 1 a i , b i 4 ( 1 i 3 ) 1≤ai,bi≤4(1≤i≤3) 1ai,bi4(1i3)
  • a i ai ai and b i bi bi are different. ( 1 i 3 ) (1≤i≤3) (1i3)
  • No two roads connect the same pair of towns.
  • Any town can be reached from any other town using the roads.

Output:

If we can visit all the towns by traversing each of the roads exactly once, print YES; otherwise, print NO.

Sample Input:

4 2
1 3
2 3

Sample Output:

YES

Sample Input:

3 2
2 4
1 2

Sample Output:

NO

Sample Input:

2 1
3 2
4 3

Sample Output:

YES

题目链接

判断四个顶点的图是否为欧拉图或半欧拉图

欧拉图所有顶点均为偶度,半欧拉图有且仅有两个顶点为奇度,直接判定即可

AC代码:

#include <bits/stdc++.h>
using namespace std;

int Deg[5];
set<int> Flag;
int Cnt;

int main(int argc, char *argv[]) {
    for (int i = 1; i <= 4; ++i) Flag.insert(i);
    for (int i = 0, A, B; i < 3; ++i) {
        scanf("%d%d", &A, &B);
        Deg[A]++; Deg[B]++;
        Flag.erase(A); Flag.erase(B);
    }
    if (!Flag.empty()) {
        printf("NO\n");
        return 0;
    }
    for (int i = 1; i <= 4; ++i) {
        if (Deg[i] & 1) {
            Cnt++;
        }
    }
    if (Cnt != 2) printf("NO\n");
    else printf("YES\n");
    return 0;
}

C - When I hit my pocket…

Description:

Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K K K times in total, in the order he likes:

  • Hit his pocket, which magically increases the number of biscuits by one.
  • Exchange A A A biscuits to 1 1 1 yen.
  • Exchange 1 1 1 yen to B B B biscuits.

Find the maximum possible number of biscuits in Snuke’s pocket after K K K operations.

Input:

Input is given from Standard Input in the following format:

K K K A A A B B B

  • 1 K , A , B 1 0 9 1≤K,A,B≤10^9 1K,A,B109
  • K , A K,A K,A and B B B are integers.

Output:

Print the maximum possible number of biscuits in Snuke’s pocket after K K K operations.

Sample Input:

4 2 6

Sample Output:

7

Sample Input:

7 3 4

Sample Output:

8

Sample Input:

314159265 35897932 384626433

Sample Output:

48518828981938099

题目链接

Snuke 一开始有 1 1 1 块饼干和 0 0 0 元钱,每次操作他可以加一块饼干或用 A A A 块饼干换 1 1 1 元钱或用 1 1 1 元钱换 B B B 块饼干,求 K K K 次操作后的饼干数量最大值

Snuke 每次用 A A A 块饼干换到 B B B 块需要进行 2 2 2 次操作,所以当 A B 1 A\ge B-1 AB1 时没有直接增加一块饼干更优否则就每两次用 A A A 块饼干换到 B B B

AC代码:

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll K, A, B;
ll Ans;

int main(int argc, char *argv[]) {
    scanf("%lld%lld%lld", &K, &A, &B);
    if (A >= B - 1 || K <= A - 1) {
        printf("%lld\n", K + 1);
        return 0;
    }
    Ans = 1;
    K -= A - 1; Ans += A - 1;
    Ans -= (K / 2) * A;
    Ans += (K / 2) * B;
    if (K & 1) Ans++;
    printf("%lld\n", Ans);
    return 0;
}
全部评论

相关推荐

秋招进行到现在终于能写总结了。完全没想到战线会拉这么长,过程会如此狼狈,不过更应该怪自己太菜了。好在所有的运气都用在了最后,也是有个去处。背景:双2本硕科班,无竞赛,本科一段研究所实习,硕士一段大厂暑期实习但无转正。技术栈是C++&nbsp;&amp;&nbsp;Golang,实习是客户端音视频(而且是鸿蒙端开发),简历两个C++项目一个Golang项目。主要投递岗位:后端,cpp软开,游戏服务端,测开,以及一些不拘泥于Java的岗位。从8月起总共投递123家公司,笔试数不清了,约面大约30家。offer/oc/意向:友塔游戏(第一个offer,面试体验很好,就是给钱好少南瑞继保(计算机科班点击就送(限男生),不...
乡土丁真真:佬很厉害,羡慕~虽然我还没有到校招的时候,也想讲一下自己的看法:我觉得不是CPP的问题,佬的背书双2,技术栈加了GO,有两段实习。投了123,面了30.拿到11个offer。这个数据已经很耀眼了。这不也是CPP带来的吗?当然也不止是CPP。至少来说在这个方向努力过的也会有好的结果和选择。同等学历和项目选java就会有更好的吗?我个人持疑问态度。当然CPP在方向选择上确实让人头大,但是我觉得能上岸,至于最后做什么方向,在我看来并不重要。至于CPP特殊,有岗位方向的随机性,java不是不挑方向,只是没得选而已。也希望自己以后校招的时候能offer满满
点赞 评论 收藏
分享
ArisRobert:统一解释一下,第4点的意思是,公司按需通知员工,没被通知到的员工是没法去上班的,所以只要没被通知到,就自动离职。就是一种比较抽象的裁员。
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务