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
Aand 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 ...
随机推荐
- zabbix 用户自定义监控参数添加
1. item key的添加 key可以带参数,该参数为一个数组列表,可以同时传递多个参数,key的格式如下 key -- [ parameters] -- 例如: vfs.fs.size[/] v ...
- mysql的navicat注册码生成
首先下载安装Navicat在Navicat关闭的情况下运行注册机在注册机界面点击patch,选择Navicat安装目录下的Navicat.exe打补丁弹出破解成功后拔掉网线断网products选择my ...
- AndroidManifest配置之uses-sdk
uses-sdk配置 uses-sdk用来设置app对android系统的兼容性.它包含三个可选的配置项,分别为android:minSdkVersion,android:targetSdkVersi ...
- js 分享代码--完整示例代码
<div class="bdsharebuttonbox" data-tag="share_1"> <a class="bds_ms ...
- PHP中的关系判断和注释
== 只判断内容,不判断类型=== 全等于,即判断内容,又判断类型 != 不等于,只判断内容,不判断类型 !== 全不等于,即判断内容,又判断类型
- Linux-用户和权限
1 Linux所有内容都是文件 归一的思想 面向对象的思想 文件只需要做增删改查的操作 2 延迟读取 一般的文本读取工具都是先将内容全部都读入内存中 cat的机制不同 是读一行显示一行 这与它的功能有 ...
- object_test.py
#方法,属性,私有化加双下划线 ''' __a 从外部无法访问,但是类的内部可以访问.实际上还是能在类外访问这些私有方法,尽管不应该这么做:s._A__a 如果不需要使用这种方法但是又不行让其他对象不 ...
- July Cook-Off 2017
Chang and Bitwise OR 分析:因为按位或最后肯定小于等于加,所以把所有数按位或即可 #include "iostream" #include "cstd ...
- Tinyplay
android里面的目录:external/tinyalsa 编译: 1. cd external/tinyalsa/ 2. vi Android.mk 3. mmm . 4. 拷贝出可执行文件 执行 ...
- 双重检查锁实现单例(java)
单例类在Java开发者中非常常用,但是它给初级开发者们造成了很多挑战.他们所面对的其中一个关键挑战是,怎样确保单例类的行为是单例?也就是说,无论任何原因,如何防止单例类有多个实例.在整个应用生命周期中 ...