AtCoder Beginner Contest 053 ABCD题
A - ABC/ARC
Time limit : 2sec / Memory limit : 256MB
Score : 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 ABC
if Smeke will participate in ABC, and print ARC
otherwise.
Constraints
- 1≦x≦3,000
- x is an integer.
Input
The input is given from Standard Input in the following format:
x
出力
Print the answer.
Sample Input 1
1000
Sample Output 1
ABC
Smeke's current rating is less than 1200, thus the output should be ABC
.
Sample Input 2
2000
Sample Output 2
ARC
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<)
{
cout<<"ABC";
}
else
{
cout<<"ARC";
}
return ;
}
B - A to Z String
Time limit : 2sec / Memory limit : 256MB
Score : 200 points
Problem Statement
Snuke has decided to construct a string that starts with A
and 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 A
and ends with Z
.
Constraints
- 1≦|s|≦200,000
- s consists of uppercase English letters.
- There exists a substring of s that starts with
A
and ends withZ
.
Input
The input is given from Standard Input in the following format:
s
Output
Print the answer.
Sample Input 1
QWERTYASDFZXCV
Sample Output 1
5
By taking out the seventh through eleventh characters, it is possible to construct ASDFZ
, which starts with A
and ends with Z
.
Sample Input 2
ZABCZ
Sample Output 2
4
Sample Input 3
HASFJGHOGAKZZFEGA
Sample Output 3
12
题意:求从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=;i<l;i++)
{
if(s[i]=='A')
{
st=i+;
break;
}
}
for(int i=;i<l;i++)
{
if(s[i]=='Z')
{
e=i+;
}
}
cout<<e-st+<<endl;
return ;
}
C - X: Yet Another Die Game
Time limit : 2sec / Memory limit : 256MB
Score : 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≦1015
- x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Sample Input 1
7
Sample Output 1
2
Sample Input 2
149696127901
Sample Output 2
27217477801
题意:
给你一个色子,初始的时候任意一个面朝上,每次操作可以将色子翻一下,并且得到此时面朝上的点数并相加,
问你想要得到至少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=;
sum+=*(n/);
n%=;
sum+=*(n/);
n%=;
sum+=*(n/);
n%=;
sum+=*(n/);
n%=;
sum+=*(n/);
n%=;
if(n==)
{
cout<<sum<<endl;
}
else
{
cout<<sum+<<endl;
}
return ;
}
D - Card Eater
Time limit : 2sec / Memory limit : 256MB
Score : 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≦105
- N 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
5
1 2 1 3 7
Sample Output 1
3
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
15
1 3 5 2 1 3 2 8 8 6 2 6 11 1 1
Sample Output 2
7
题意:我们每次选择三张牌,去掉最大最小牌,留下一张放回,问最后能留下多少种唯一的牌
解法:每次我们是减去两张,题目给了奇数个,那么留下总数的必定是奇数,我们去重之后看能够得到多少种,偶数种再减去一,奇数保留。
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
int a[];
cin>>n;
for(int i=;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
int x=unique(a,a+n)-a;
if(x%)
{
cout<<x;
}
else
{
cout<<x-;
}
return ;
}
AtCoder Beginner Contest 053 ABCD题的更多相关文章
- AtCoder Beginner Contest 068 ABCD题
A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contes ...
- AtCoder Beginner Contest 069 ABCD题
题目链接:http://abc069.contest.atcoder.jp/assignments A - K-City Time limit : 2sec / Memory limit : 256M ...
- AtCoder Beginner Contest 070 ABCD题
题目链接:http://abc070.contest.atcoder.jp/assignments A - Palindromic Number Time limit : 2sec / Memory ...
- AtCoder Beginner Contest 057 ABCD题
A - Remaining Time Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Dol ...
- AtCoder Beginner Contest 051 ABCD题
A - Haiku Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement As a New Yea ...
- AtCoder Beginner Contest 052 ABCD题
A - Two Rectangles Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement The ...
- AtCoder Beginner Contest 054 ABCD题
A - One Card Poker Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Ali ...
- AtCoder Beginner Contest 058 ABCD题
A - ι⊥l Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Three poles st ...
- AtCoder Beginner Contest 050 ABC题
A - Addition and Subtraction Easy Time limit : 2sec / Memory limit : 256MB Score : 100 points Proble ...
随机推荐
- MVC vs MVP vs MVVM
一.MVC MVC模式的意思是,软件可以分成三个部分. 视图(View):用户界面. 控制器(Controller):业务逻辑 模型(Model):数据保存 各部分之间的通信方式如下. View 传送 ...
- Gradients渐变属性
一个很不错的网站http://www.w3schools.com/css/css3_gradients.asp http://www.w3cplus.com/css3/new-css3-linear- ...
- hihocoder 挑战赛9 A.好配对(思维题目 防止超时)
#1123 : 好配对 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 给定两个序列a和b,每个序列中可能含有重复的数字. 一个配对(i,j)是一个好配对当从第一个序列中选 ...
- Gym - 100283K K. Cubes Shuffling —— 贪心
题目链接:http://codeforces.com/gym/100283/problem/K 题解: 要使其相邻两项的差值之和最小,那么越靠中间,其数值越小. 那么剩下的问题就是如何放数字了.一开始 ...
- CSU - 1547 Rectangle —— DP(01背包)
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1547 题解: 关键是怎么处理长度为1的长方形.当长度为1的长方形的个数cnt> ...
- ffmpeg av_interleaved_write_frame Operation not permitted
今天在使用ffmpeg时出现了Operation not permitted通过增加打印信息发现是在av_interleaved_write_frame出现的问题, 昨天还没出现这个问题,很奇怪,就把 ...
- 【转载】 C++中回车换行(\n\r)和换行(\r)的区别
原文:http://blog.csdn.net/xiaofei2010/article/details/8458605 windows下的点一下回车,效果是:回车换行,就是\r\n unix系统下的回 ...
- ACM2016级新生第三周训练赛
本次是弱校题解-比赛链接 备用链接 题目还是比较基础,比较简单.认真补题,学会学习. A -人见人爱A^B 题解: 求 A的B次方,我们可以用循环进行累乘操作,进而计算出次方.因为题目要求只需要求出最 ...
- [AH2017/HNOI2017]抛硬币
传送门 这个题的暴力比较好想--然后用一些组合的知识就可以变成正解了. 首先我们考虑a=b的情况.我们把扔出来的硬币看成是一个01序列,那么对于一个b获胜的序列,他在每一位都按位异或1之后必然是一个a ...
- MTK UART串口调试
一.UART初始化 1. kernel-3.18/drivers/misc/mediatek/uart/uart.c static int __init mtk_uart_init(void) { ; ...