Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
1 文字目が数字、2 文字目が文字 x、3 文字目が数字であるような 3 文字の文字列 S が与えられます。
S の 2 つの数の積を求めてください。
制約
- S は 1 文字目が 1 以上 9 以下の整数、2 文字目が文字
x、3 文字目が 1 以上 9 以下の整数であるような 3 文字の文字列
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを整数として出力せよ。
入力例 1
3x8
出力例 1
24
3 \times 8 = 24 より、24 を出力します。
入力例 2
9x9
出力例 2
81
9 \times 9 = 81 より、81 を出力します。
Score : 100 points
Problem Statement
You are given a 3-character string S, where the first character is a digit, the second character is the character x, and the third character is a digit.
Find the product of the two numbers in S.
Constraints
- S is a 3-character string where the first character is an integer between 1 and 9, inclusive, the second character is the character
x, and the third character is an integer between 1 and 9, inclusive.
Input
The input is given from Standard Input in the following format:
S
Output
Print the answer as an integer.
Sample Input 1
3x8
Sample Output 1
24
From 3 \times 8 = 24, print 24.
Sample Input 2
9x9
Sample Output 2
81
From 9 \times 9 = 81, print 81.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
整数 A, B が与えられます。 A^B の値を出力してください。
制約
- 1 \leq A, B \leq 9
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
A B
出力
答えを出力せよ。
入力例 1
4 3
出力例 1
64
4^3 = 64 であるので、64 を出力します。
入力例 2
5 5
出力例 2
3125
入力例 3
8 1
出力例 3
8
Score : 100 points
Problem Statement
Given integers A and B, print the value A^B.
Constraints
- 1 \leq A, B \leq 9
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
A B
Output
Print the answer.
Sample Input 1
4 3
Sample Output 1
64
4^3 = 64, so 64 should be printed.
Sample Input 2
5 5
Sample Output 2
3125
Sample Input 3
8 1
Sample Output 3
8
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
高橋くんは、現在 N 枚のカードを持っています。 i 番目 (1\le i\le N) のカードには整数 A _ i が書かれています。
高橋くんは、以下の操作を可能な限り繰り返します。
- 同じ整数が書かれている異なる 2 枚のカードを選び、それら 2 枚のカードを食べる。食べたカードは永久に取り除かれ、以降の操作で選ぶことはできない。
操作ができなくなったときに残っているカードに書かれている整数の合計を求めてください。
制約
- 1\le N\le100
- 1\le A _ i\le100\ (1\le i\le N)
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N A _ 1 A _ 2 \cdots A _ N
出力
残ったカードに書かれている整数の合計を出力せよ。
入力例 1
8 2 7 1 8 2 8 1 8
出力例 1
15
例えば、高橋くんは以下のように操作を行います。
- 4 枚目のカードと 6 枚目のカードにはどちらも 8 が書かれているため、それらを選び、食べる。
- 1 枚目のカードと 5 枚目のカードにはどちらも 2 が書かれているため、それらを選び、食べる。
- 3 枚目のカードと 7 枚目のカードにはどちらも 1 が書かれているため、それらを選び、食べる。

よって、残ったカードに書かれている整数の合計は 7+8=15 です。
8 と書かれたカードは 3 枚あるので、これらのうちの 2 枚を食べると残った 1 枚は食べられないことに注意してください。
入力例 2
5 1 2 3 4 5
出力例 2
15
高橋くんが操作を一度も行えない場合もあります。
入力例 3
15 58 97 74 16 97 74 97 16 51 52 58 52 74 32 43
出力例 3
297
Score : 200 points
Problem Statement
Takahashi currently has N cards. The i-th (1\le i\le N) card has the integer A _ i written on it.
He repeats the following operation as many times as possible.
- Choose two different cards with the same integer written on them, and eat those two cards. The eaten cards are permanently removed and cannot be chosen in subsequent operations.
Find the sum of the integers written on the cards that remain when the operation can no longer be performed.
Constraints
- 1\le N\le100
- 1\le A _ i\le100\ (1\le i\le N)
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A _ 1 A _ 2 \cdots A _ N
Output
Output the sum of the integers written on the remaining cards.
Sample Input 1
8 2 7 1 8 2 8 1 8
Sample Output 1
15
For example, Takahashi operates as follows.
- The fourth card and sixth card both have 8 written on them, so he chooses them and eats them.
- The first card and fifth card both have 2 written on them, so he chooses them and eats them.
- The third card and seventh card both have 1 written on them, so he chooses them and eats them.

Thus, the sum of the integers written on the remaining cards is 7+8=15.
Note that there are three cards with 8 written on them, so once two of them are eaten, the remaining one cannot be eaten.
Sample Input 2
5 1 2 3 4 5
Sample Output 2
15
It is possible that Takahashi cannot perform the operation even once.
Sample Input 3
15 58 97 74 16 97 74 97 16 51 52 58 52 74 32 43
Sample Output 3
297
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
以下の図で表される正五角形 P があります。

P の点 S_1 と点 S_2 を結ぶ線分と、点 T_1 と点 T_2 を結ぶ線分の長さが等しいか判定してください。
制約
- S_1,S_2,T_1,T_2 は
A,B,C,D,Eのいずれかの文字 - S_1 \neq S_2
- T_1 \neq T_2
入力
入力は以下の形式で標準入力から与えられる。
S_1S_2 T_1T_2
出力
P の点 S_1 と点 S_2 を結ぶ線分と、点 T_1 と点 T_2 を結ぶ線分の長さが等しい場合 Yes を、等しくない場合 No を出力せよ。
入力例 1
AC EC
出力例 1
Yes
P の点 A と点 C を結ぶ線分と、P の点 E と点 C を結ぶ線分の長さは等しいです。
入力例 2
DA EA
出力例 2
No
P の点 D と点 A を結ぶ線分と、P の点 E と点 A を結ぶ線分の長さは等しくありません。
入力例 3
BD BD
出力例 3
Yes
Score : 200 points
Problem Statement
A regular pentagon P is shown in the figure below.

Determine whether the length of the line segment connecting points S_1 and S_2 of P equals the length of the line segment connecting points T_1 and T_2.
Constraints
- Each of S_1, S_2, T_1, and T_2 is one of the characters
A,B,C,D, andE. - S_1 \neq S_2
- T_1 \neq T_2
Input
The input is given from Standard Input in the following format:
S_1S_2 T_1T_2
Output
If the length of the line segment connecting points S_1 and S_2 of P equals the length of the line segment connecting points T_1 and T_2, print Yes; otherwise, print No.
Sample Input 1
AC EC
Sample Output 1
Yes
The length of the line segment connecting point A and point C of P equals the length of the line segment connecting point E and point C.
Sample Input 2
DA EA
Sample Output 2
No
The length of the line segment connecting point D and point A of P does not equal the length of the line segment connecting point E and point A.
Sample Input 3
BD BD
Sample Output 3
Yes
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
AtCoder 国には「トラック運転手は A 分以上運転する際には B 分以上の休憩を取らなければならない」というルールがあります。
a, b からなる長さ N の文字列 S と正整数 A,B が与えられます。以下の条件を全て満たす整数組 (l,r) の個数を求めてください。
- 1\leq l \leq r \leq N
- S の l 文字目から r 文字目までに含まれる
aの個数が A 以上 - S の l 文字目から r 文字目までに含まれる
bの個数が B 未満
制約
- 1\leq N \leq 3\times 10^5
- 1 \leq A,B \leq N
- S は
a,bのみからなる長さ N の文字列 - 与えられる数値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N A B S
出力
答えを出力せよ。
入力例 1
11 4 2 abbaaabaaba
出力例 1
3
条件を満たす (l,r) の組は (4,8),(4,9),(5,9) の 3 個です。
入力例 2
13 1 2 bbbbbbbbbbbbb
出力例 2
0
条件を満たす (l,r) の組は存在しません。
Score : 300 points
Problem Statement
In AtCoder Country, there is a rule that "a truck driver must take a break of at least B minutes when driving for A minutes or more."
You are given a string S of length N consisting of a and b, and positive integers A and B. Find the number of integer pairs (l,r) that satisfy all of the following conditions.
- 1\leq l \leq r \leq N
- The number of
ain the substring from the l-th character through the r-th character of S is greater than or equal to A. - The number of
bin the substring from the l-th character through the r-th character of S is less than B.
Constraints
- 1\leq N \leq 3\times 10^5
- 1 \leq A,B \leq N
- S is a string of length N consisting of
aandb. - All input numbers are integers.
Input
The input is given from Standard Input in the following format:
N A B S
Output
Print the answer.
Sample Input 1
11 4 2 abbaaabaaba
Sample Output 1
3
The pairs (l,r) that satisfy the conditions are (4,8),(4,9),(5,9), which is three pairs.
Sample Input 2
13 1 2 bbbbbbbbbbbbb
Sample Output 2
0
There are no pairs (l,r) that satisfy the conditions.