> 文档中心 > Acwing周赛 1,2题+AtCoder Beginner Contest 1,2题

Acwing周赛 1,2题+AtCoder Beginner Contest 1,2题

目录

Acwing

A

B

ABC

A

Problem Statement

Constraints

Input

Output

Sample Input 1 Copy

Sample Output 1 Copy

Sample Input 2 Copy

Sample Output 2 Copy

Sample Input 3 Copy

Sample Output 3 Copy

B

Problem Statement

Constraints

Input

Output

Sample Input 1 Copy

Sample Output 1 Copy

Sample Input 2 Copy

Sample Output 2 Copy

Sample Input 3 Copy

Sample Output 3 Copy

Sample Input 4 Copy

Sample Output 4 Copy


Acwing

A

小明家里有 nn 个鸡蛋

每天早上,小明都要吃 11 个鸡蛋作为早餐。

小明家里还有一个母鸡。

母鸡会在第 m,2m,3m…m,2m,3m… 天的晚上下蛋,每次只下 11 个蛋。

请问,连续多少天以后,小明就没有早餐鸡蛋吃了?

输入格式

一行两个整数 n,mn,m。

输出格式

一个整数,表示答案。

数据范围

所有测试点满足 1≤n≤1001≤n≤100,2≤m≤1002≤m≤100。

输入样例1:

2 2

输出样例1:

3

样例1解释

第 1,21,2 天的早晨,小明可以吃原本就有的鸡蛋。

第 33 天的早晨,小明可以吃第 22 天晚上母鸡下的鸡蛋。

第 44 天的早晨,小明没有鸡蛋可以吃了。

所以,连续 33 天以后,小明就没有早餐鸡蛋可以吃了。

输入样例2:

9 3

输出样例2:

13

样例2解释

第 1∼91∼9 天的早晨,小明可以吃原本就有的鸡蛋。

第 10,11,1210,11,12 天的早晨,小明可以吃第 3,6,93,6,9 天晚上母鸡下的蛋。

第 1313 天的早晨,小明可以吃第 1212 天晚上母鸡下的蛋。

第 1414 天的早晨,小明没有鸡蛋可以吃了。

所以,连续 1313 天以后,小明就没有早餐鸡蛋可以吃了。

#includeusing namespace std;int main(){int n,m;cin>>n>>m;int day = 0;int c = m;while(n){n = n-1;day++;if(day == c){n+=1;c = m+c;}}cout<<day<<endl;return 0;}

 

B

三个倒扣着的不透明小碗排成一排。

随机挑选一个小碗,将一个小球置于碗中。

然后进行 nn 次操作,编号 1∼n1∼n。

对于第 ii 次操作:

  • 如果 imod2=1imod2=1,则操作内容为将位于中间的碗和位于左边的碗交换位置。
  • 如果 imod2=0imod2=0,则操作内容为将位于中间的碗和位于右边的碗交换位置。

我们不妨用 0,1,20,1,2 来表示左、中、右三个位置。

nn 次操作全部完成以后,装有小球的碗位于位置 xx。

请你计算,所有操作开始前,装有小球的碗所在的初始位置。

输入格式

第一行,一个整数 nn。

第二行,一个整数 xx。

输出格式

输出一个 0∼20∼2 的整数,表示所有操作开始前,装有小球的碗所在的初始位置。

数据范围

前 66 个测试点满足 1≤n≤51≤n≤5。
所有测试点满足 1≤n≤2×1091≤n≤2×109,0≤x≤20≤x≤2。

输入样例1:

42

输出样例1:

1

输入样例2:

11

输出样例2:

0
#includeusing namespace std;typedef long long ll;ll n;int main(){int x;int a[3] = {0,1,2};cin>>n>>x;n%=6;for(int i = 0;i<n;i++){if(i%2 == 0)swap(a[0],a[1]);else swap(a[1],a[2]);}cout<<a[x];return 0;}

 

ABC

A

A - Jogging Editorial

 / 


Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 100100 points

Problem Statement

Takahashi and Aoki decided to jog.
Takahashi repeats the following: "walk at BB meters a second for AA seconds and take a rest for CC seconds."
Aoki repeats the following: "walk at EE meters a second for DD seconds and take a rest for FF seconds."
When XX seconds have passed since they simultaneously started to jog, which of Takahashi and Aoki goes ahead?

Constraints

  • 1 \leq A, B, C, D, E, F, X \leq 1001≤A,B,C,D,E,F,X≤100
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

AA BB CC DD EE FF XX

Output

When XX seconds have passed since they simultaneously started to jog, if Takahashi goes ahead of Aoki, print Takahashi; if Aoki goes ahead of Takahashi, print Aoki; if they have advanced the same distance, print Draw.


Sample Input 1 Copy

Copy

4 3 3 6 2 5 10

Sample Output 1 Copy

Copy

Takahashi

During the first 1010 seconds after they started to jog, they move as follows.

  • Takahashi walks for 44 seconds, takes a rest for 33 seconds, and walks again for 33 seconds. As a result, he advances a total of (4 + 3) \times 3 = 21(4+3)×3=21 meters.
  • Aoki walks for 66 seconds and takes a rest for 44 seconds. As a result, he advances a total of 6 \times 2 = 126×2=12 meters.

Since Takahashi goes ahead, Takahashi should be printed.


Sample Input 2 Copy

Copy

3 1 4 1 5 9 2

Sample Output 2 Copy

Copy

Aoki

Sample Input 3 Copy

Copy

1 1 1 1 1 1 1

Sample Output 3 Copy

Copy

Draw

 

#include using namespace std;int main(){    int a, b, c, d, e, f, x;    cin >> a >> b >> c >> d >> e >> f >> x;    int t = x / (a + c) * a + ((x % (a + c) > a) ? a : x % (a + c));    int ao = x / (d + f) * d + ((x % (d + f) > d) ? d : x % (d + f));    if (t * b == ao * e)    { cout < t * b)    { cout << "Aoki";    }    else    { cout << "Takahashi";    }}

B

B - Perfect String Editorial

 / 


Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 200200 points

Problem Statement

Let us call a string consisting of uppercase and lowercase English alphabets a wonderful string if all of the following conditions are satisfied:

  • The string contains an uppercase English alphabet.
  • The string contains a lowercase English alphabet.
  • All characters in the string are pairwise distinct.

For example, AtCoder and Aa are wonderful strings, while atcoder and Perfect are not.

Given a string SS, determine if SS is a wonderful string.

Constraints

  • 1 \le |S| \le 1001≤∣S∣≤100
  • SS is a string consisting of uppercase and lowercase English alphabets.

Input

Input is given from Standard Input in the following format:

SS

Output

If SS is a wonderful string, print Yes; otherwise, print No.


Sample Input 1 Copy

Copy

AtCoder

Sample Output 1 Copy

Copy

Yes

AtCoder is a wonderful string because it contains an uppercase English alphabet, a lowercase English alphabet, and all characters in the string are pairwise distinct.


Sample Input 2 Copy

Copy

Aa

Sample Output 2 Copy

Copy

Yes

Note that A and a are different characters. This string is a wonderful string.


Sample Input 3 Copy

Copy

atcoder

Sample Output 3 Copy

Copy

No

It is not a wonderful string because it does not contain an uppercase English alphabet.


Sample Input 4 Copy

Copy

Perfect

Sample Output 4 Copy

Copy

No

It is not a wonderful string because the 22-nd and the 55-th characters are the same.

 

#includeusing namespace std;int main(){string s;cin>>s;int n = s.size();bool ok1 = false;bool ok2 = true;bool ok3 = true;for(int i = 0;i<n-1;i++){for(int j = i+1;j<n;j++){if(s[i] == s[j]){ok1 = true;}}}for(int i = 0;i='a'&&s[i]<='z'){}else{ok2 = false;}}for(int i = 0;i='A'&&s[i]<='Z'){}else{ok3 = false;break;}}if(ok1||ok2||ok3){cout<<"No"<<endl;}else{cout<<"Yes"<<endl;}return 0;}