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:

  1. x

出力

Print the answer.


Sample Input 1

Copy
  1. 1000

Sample Output 1

Copy
  1. ABC

Smeke's current rating is less than 1200, thus the output should be ABC.


Sample Input 2

Copy
  1. 2000

Sample Output 2

Copy
  1. ARC

Smeke's current rating is not less than 1200, thus the output should be ARC.

题意:1200分作为区分,问打哪一场比赛

解法:模拟

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int n;
  6. cin>>n;
  7. if(n<)
  8. {
  9. cout<<"ABC";
  10. }
  11. else
  12. {
  13. cout<<"ARC";
  14. }
  15. return ;
  16. }

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 with Z.

Input

The input is given from Standard Input in the following format:

  1. s

Output

Print the answer.


Sample Input 1

Copy
  1. QWERTYASDFZXCV

Sample Output 1

Copy
  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

Copy
  1. ZABCZ

Sample Output 2

Copy
  1. 4

Sample Input 3

Copy
  1. HASFJGHOGAKZZFEGA

Sample Output 3

Copy
  1. 12
    题意:求从A开始到Z最长的字符串能有多长
    解法:找到最先出现的A,和最后出现的Z,然后就求长度就行
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int st,e;
  6. string s;
  7. cin>>s;
  8. int l=s.length();
  9. for(int i=;i<l;i++)
  10. {
  11. if(s[i]=='A')
  12. {
  13. st=i+;
  14. break;
  15. }
  16. }
  17. for(int i=;i<l;i++)
  18. {
  19. if(s[i]=='Z')
  20. {
  21. e=i+;
  22. }
  23. }
  24. cout<<e-st+<<endl;
  25. return ;
  26. }

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:

  1. x

Output

Print the answer.


Sample Input 1

Copy
  1. 7

Sample Output 1

Copy
  1. 2

Sample Input 2

Copy
  1. 149696127901

Sample Output 2

Copy
  1. 27217477801
    题意:

给你一个色子,初始的时候任意一个面朝上,每次操作可以将色子翻一下,并且得到此时面朝上的点数并相加,

问你想要得到至少X分,最少需要多少次操作。

解法:我们两次能得到的最大点之和11,10,9,8,7,小于7的我们翻一次就行

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. int main()
  5. {
  6. ll n;
  7. cin>>n;
  8. ll sum=;
  9. sum+=*(n/);
  10. n%=;
  11. sum+=*(n/);
  12. n%=;
  13. sum+=*(n/);
  14. n%=;
  15. sum+=*(n/);
  16. n%=;
  17. sum+=*(n/);
  18. n%=;
  19. if(n==)
  20. {
  21. cout<<sum<<endl;
  22. }
  23. else
  24. {
  25. cout<<sum+<<endl;
  26. }
  27. return ;
  28. }

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:

  1. N
  2. A1 A2 A3 ... AN

Output

Print the answer.


Sample Input 1

Copy
  1. 5
  2. 1 2 1 3 7

Sample Output 1

Copy
  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: 13 and 7.


Sample Input 2

Copy
  1. 15
  2. 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1

Sample Output 2

Copy
  1. 7

题意:我们每次选择三张牌,去掉最大最小牌,留下一张放回,问最后能留下多少种唯一的牌

解法:每次我们是减去两张,题目给了奇数个,那么留下总数的必定是奇数,我们去重之后看能够得到多少种,偶数种再减去一,奇数保留。

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int n;
  6. int a[];
  7. cin>>n;
  8. for(int i=;i<n;i++)
  9. {
  10. cin>>a[i];
  11. }
  12. sort(a,a+n);
  13. int x=unique(a,a+n)-a;
  14. if(x%)
  15. {
  16. cout<<x;
  17. }
  18. else
  19. {
  20. cout<<x-;
  21. }
  22. return ;
  23. }
  1.  

AtCoder Beginner Contest 053 ABCD题的更多相关文章

  1. AtCoder Beginner Contest 068 ABCD题

    A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contes ...

  2. AtCoder Beginner Contest 069 ABCD题

    题目链接:http://abc069.contest.atcoder.jp/assignments A - K-City Time limit : 2sec / Memory limit : 256M ...

  3. AtCoder Beginner Contest 070 ABCD题

    题目链接:http://abc070.contest.atcoder.jp/assignments A - Palindromic Number Time limit : 2sec / Memory ...

  4. AtCoder Beginner Contest 057 ABCD题

    A - Remaining Time Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Dol ...

  5. AtCoder Beginner Contest 051 ABCD题

    A - Haiku Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement As a New Yea ...

  6. AtCoder Beginner Contest 052 ABCD题

    A - Two Rectangles Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement The ...

  7. AtCoder Beginner Contest 054 ABCD题

    A - One Card Poker Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Ali ...

  8. AtCoder Beginner Contest 058 ABCD题

    A - ι⊥l Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Three poles st ...

  9. AtCoder Beginner Contest 050 ABC题

    A - Addition and Subtraction Easy Time limit : 2sec / Memory limit : 256MB Score : 100 points Proble ...

随机推荐

  1. [haoi2015]T1

    题意:给定你一颗树,要求你在这棵树中确定K个黑点和N-K个白点,使黑点间与白点间两两距离之和最大,输出最大值.n<=2000 对于这道题,我想了好几个思路,包括点分治,贪心,动规,网络流等等,实 ...

  2. ubuntu 12.04安装alsa-lib、alsa-utils【转】

    1. alsa-lib ./configure sudo make install 注意:默认是安装到/usr/这个目录下面,但是我测试多了多次,安装了alsa-lib之后,系统就没有声音了,也没有找 ...

  3. SVG-Android开源库——SVG生成Vector资源文件的编辑预览工具

    Vector矢量图在Android项目中的应用越来越广泛,但是如果你想用Android Studio自带的工具将SVG图片转化成Vector资源文件却是相当麻烦,首先能支持的SVG规范较少,其次操作流 ...

  4. Android Studio 使用Gradle多渠道打包

    第一步:配置AndroidManifest.xml 以友盟渠道为例,渠道信息一般都是写在 AndroidManifest.xml文件中,大约如下: <meta-data android:name ...

  5. linux系统CentOS6.5下tokudb数据库引擎的安装

    tokuDB是一个关于mysql数据引擎的开源项目,官网对其特点的描述主要有三点: 1.高压缩比,官方宣称可以达到1:12. 2.高insert性能,官方称至少比innodb高9倍. 3.可以在线添加 ...

  6. 「LuoguP3376」 【模板】网络最大流

    题目描述 如题,给出一个网络图,以及其源点和汇点,求出其网络最大流. 输入输出格式 输入格式: 第一行包含四个正整数N.M.S.T,分别表示点的个数.有向边的个数.源点序号.汇点序号. 接下来M行每行 ...

  7. pytest用例setup和teardown

    函数式以下两种: setup_function/teardown_function  每个用例开始和结束调用一次 setup_module/teardown_module     setup_modu ...

  8. Foreign Postcards

    题意: 给定 n 张排成一堆的的卡片,每一次从堆顶上等概率随机取出 [1~当前卡片数] 个卡片,如果堆顶的卡片是反面朝上, 则将所有取出的卡片翻转,求问期望取出多少个反面朝上的卡片. 解法: 考虑dp ...

  9. mongodb和mysql语法对比

    MySQL: SELECT * FROM user Mongo: db.user.find() —————————————— MySQl: SELECT * FROM user WHERE name ...

  10. UVaLive 3902 Network (无根树转有根树,贪心)

    题意:一个树形网络,叶子是客户端,其他的是服务器.现在只有一台服务器提供服务,使得不超k的客户端流畅,但是其他的就不行了, 现在要在其他结点上安装服务器,使得所有的客户端都能流畅,问最少要几台. 析: ...