AtCoder Beginner Contest 053 ABCD题
2017-02-13 20:46
435 查看
A - ABC/ARC
Time limit : 2sec / Memory limit : 256MBScore : 100 points
Problem Statement
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.You are given Smeke's current rating, x. Print
ABCif Smeke will participate in ABC, and print
ARCotherwise.
Constraints
1≦x≦3,000x is an integer.
Input
The input is given from Standard Input in the following format:x
出力
Print the answer.Sample Input 1
Copy1000
Sample Output 1
CopyABC
Smeke's current rating is less than 1200, thus the output should be
ABC.
Sample Input 2
Copy2000
Sample Output 2
CopyARC
Smeke's current rating is not less than 1200, thus the output should be
ARC.
题意:1200分作为区分,问打哪一场比赛
解法:模拟
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; if(n<1200) { cout<<"ABC"; } else { cout<<"ARC"; } return 0; }
B - A to Z String
Time limit : 2sec / Memory limit : 256MBScore : 200 points
Problem Statement
Snuke has decided to construct a string that starts withAand ends with
Z, by taking out a substring of a string s (that is, a consecutive part of s).
Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with
Aand ends with
Z.
Constraints
1≦|s|≦200,000s consists of uppercase English letters.
There exists a substring of s that starts with
Aand ends with
Z.
Input
The input is given from Standard Input in the following format:s
Output
Print the answer.Sample Input 1
CopyQWERTYASDFZXCV
Sample Output 1
Copy5
By taking out the seventh through eleventh characters, it is possible to construct
ASDFZ, which starts with
Aand ends with
Z.
Sample Input 2
CopyZABCZ
Sample Output 2
Copy4
Sample Input 3
CopyHASFJGHOGAKZZFEGA
Sample Output 3
Copy12 题意:求从A开始到Z最长的字符串能有多长 解法:找到最先出现的A,和最后出现的Z,然后就求长度就行
#include<bits/stdc++.h> using namespace std; int main() { int st,e; string s; cin>>s; int l=s.length(); for(int i=0;i<l;i++) { if(s[i]=='A') { st=i+1; break; } } for(int i=0;i<l;i++) { if(s[i]=='Z') { e=i+1; } } cout<<e-st+1<<endl; return 0; }
C - X: Yet Another Die Game
Time limit : 2sec / Memory limit : 256MBScore : 300 points
Problem Statement
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
1≦x≦1015x is an integer.
Input
The input is given from Standard Input in the following format:x
Output
Print the answer.Sample Input 1
Copy7
Sample Output 1
Copy2
Sample Input 2
Copy149696127901
Sample Output 2
Copy27217477801 题意:
给你一个色子,初始的时候任意一个面朝上,每次操作可以将色子翻一下,并且得到此时面朝上的点数并相加,
问你想要得到至少X分,最少需要多少次操作。
解法:我们两次能得到的最大点之和11,10,9,8,7,小于7的我们翻一次就行
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll n; cin>>n; ll sum=0; sum+=2*(n/11); n%=11; sum+=2*(n/10); n%=10; sum+=2*(n/9); n%=9; sum+=2*(n/8); n%=8; sum+=2*(n/7); n%=7; if(n==0) { cout<<sum<<endl; } else { cout<<sum+1<<endl; } return 0; }
D - Card Eater
Time limit : 2sec / Memory limit : 256MBScore : 400 points
Problem Statement
Snuke has decided to play a game using cards. He has a deck consisting of N cards. On the i-th card from the top, an integer Ai is written.He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept.
Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.
Constraints
3≦N≦105N is odd.
1≦Ai≦105
Ai is an integer.
Input
The input is given from Standard Input in the following format:N A1 A2 A3 ... AN
Output
Print the answer.Sample Input 1
Copy51 2 1 3 7
Sample Output 1
Copy3
One optimal solution is to perform the operation once, taking out two cards with 1 and one card with 2. One card with 1 and another with 2 will be eaten, and the remaining card with 1 will be returned to deck. Then, the values written on the remaining cards in the deck will be pairwise distinct: 1, 3 and 7.
Sample Input 2
Copy151 3 5 2 1 3 2 8 8 6 2 6 11 1 1
Sample Output 2
Copy7
题意:我们每次选择三张牌,去掉最大最小牌,留下一张放回,问最后能留下多少种唯一的牌
解法:每次我们是减去两张,题目给了奇数个,那么留下总数的必定是奇数,我们去重之后看能够得到多少种,偶数种再减去一,奇数保留。
#include<bits/stdc++.h> using namespace std; int main() { int n; int a[200000]; cin>>n; for(int i=0;i<n;i++) { cin>>a[i]; } sort(a,a+n); int x=unique(a,a+n)-a; if(x%2) { cout<<x; } else { cout<<x-1; } return 0; }
相关文章推荐
- AtCoder Beginner Contest 052 ABCD题
- AtCoder Beginner Contest 072 ABCD C++&&Python3
- AtCoder Beginner Contest 051 ABCD题
- AtCoder Beginner Contest 071 ABCD
- AtCoder Beginner Contest 058 ABCD题
- AtCoder Beginner Contest 054 ABCD题
- AtCoder Beginner Contest 061 D Score Attack(Bellman-ford)
- AtCoder Beginner Contest 067 D - Fennec VS. Snuke
- AtCoder Beginner Contest 084 C - Special Trains(思路)
- AtCoder Beginner Contest 085 C Otoshidama(计算机整数乘法问题+方程求解)
- AtCoder Beginner Contest 085 D Katana Thrower (贪心+计算机除法特性)
- AtCoder Beginner Contest 089 D - Practical Skill Test 边界处理
- AtCoder Beginner Contest 067 C - Splitting Pi
- AtCoder Beginner Contest 069
- AtCoder Beginner Contest 070 D - Transit Tree Path (DFS / LCA
- AtCoder Beginner Contest 081 D - Non-decreasing 【思维移位】
- AtCoder Beginner Contest 084 C - Special Trains(思路)
- AtCoder Beginner Contest 085 C Otoshidama(计算机整数乘法问题+方程求解)
- AtCoder Beginner Contest 085 D Katana Thrower (贪心+计算机除法特性)
- AtCoder Beginner Contest 089 D - Practical Skill Test 边界处理