Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
高橋君は自分の体温を計測し、 X {}^\circC であることがわかりました。
体温は次の 3 種類に分類されます。
- 38.0 {}^\circC 以上のとき「高熱」
- 37.5 {}^\circC 以上 38.0 {}^\circC 未満のとき「発熱」
- 37.5 {}^\circC 未満のとき「平熱」
高橋君の体温は何に分類されるでしょうか?「出力」の項にしたがって整数で出力してください。
制約
- 30 \leq X \leq 50
- X は小数第一位まで与えられる
入力
入力は以下の形式で標準入力から与えられる。
X
出力
高橋君の体温が何に分類されるかを以下に定められる整数で出力せよ。
- 高熱の場合: 1
- 発熱の場合: 2
- 平熱の場合: 3
入力例 1
40.0
出力例 1
1
高橋君の体温は 40.0 {}^\circC であるため、高熱に分類されます。よって、1 を出力します。
入力例 2
37.7
出力例 2
2
高橋君の体温は 37.7 {}^\circC であるため、発熱に分類されます。よって、2 を出力します。
入力例 3
36.6
出力例 3
3
高橋君の体温は 36.6 {}^\circC であるため、平熱に分類されます。よって、3 を出力します。
Score : 100 points
Problem Statement
Takahashi measured his body temperature and found it to be X {}^\circC.
Body temperature is classified into the following:
- Higher than or equal to 38.0 {}^\circC: “High fever”
- Higher than or equal to 37.5 {}^\circC and lower than 38.0 {}^\circC: “Fever”
- Lower than 37.5 {}^\circC: “Normal”
Which classification does Takahashi's body temperature fall into? Present the answer as an integer according to the Output section.
Constraints
- 30 \leq X \leq 50
- X is given to one decimal place.
Input
The input is given from Standard Input in the following format:
X
Output
Print an integer specified below corresponding to Takahashi's body temperature classification.
- High fever: 1
- Fever: 2
- Normal: 3
Sample Input 1
40.0
Sample Output 1
1
His body temperature is 40.0 {}^\circC, which is classified as a high fever. Thus, print 1.
Sample Input 2
37.7
Sample Output 2
2
His body temperature is 37.7 {}^\circC, which is classified as a fever. Thus, print 2.
Sample Input 3
36.6
Sample Output 3
3
His body temperature is 36.6 {}^\circC, which is classified as a normal temperature. Thus, print 3.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
高橋くんはゲームで遊んでいます。 このゲームにはワールドが 8 つあり、それぞれのワールドにはステージが 8 つずつあります。 ステージには順番があり、最初のステージは 1 個めのワールドにある 1 個めのステージです。 i 個め (1\le i\le 8) のワールドにある j 個め (1\le j\le 8) のステージの次のステージは、以下のようになっています。
- j\lt8 のとき、次のステージは i 個めのワールドにある j+1 個めのステージです。
- i\lt8,j=8 のとき、次のステージは i+1 個めのワールドにある 1 個めのステージです。
- i=8,j=8 のとき、次のステージはありません。このステージが最後のステージです。
i 個め (1\le i\le 8) のワールドにある j 個め (1\le j\le 8) のステージの名前は i-j です。
たとえば、最初のステージ名は 1-1 で、最後のステージ名は 8-8 です。
高橋くんが現在遊んでいるステージのステージ名 S が与えられるので、次のステージのステージ名を出力してください。
制約
- S はいずれかのステージのステージ名である。
- S は
8-8ではない。
入力
入力は以下の形式で標準入力から与えられる。
S
出力
次のステージのステージ名を出力せよ。
入力例 1
4-2
出力例 1
4-3
4 個めのワールドの 2 個めのステージの次のステージは、同じワールドの 3 個めのステージです。
入力例 2
1-8
出力例 2
2-1
1-8 は 1 個めのワールドの最後のステージなので、次のステージは 2 個めのワールドの 1 個めのステージです。
入力例 3
3-3
出力例 3
3-4
Score : 100 points
Problem Statement
Takahashi is playing a game. This game has eight worlds, and each world has eight stages. The stages have an order, and the first stage is the 1st stage in the 1st world. The next stage after the j-th stage (1\le j\le 8) in the i-th world (1\le i\le 8) is as follows:
- When j\lt8, the next stage is the (j+1)-th stage in the i-th world.
- When i\lt8,j=8, the next stage is the 1st stage in the (i+1)-th world.
- When i=8,j=8, there is no next stage. This stage is the last stage.
The name of the j-th stage (1\le j\le 8) in the i-th world (1\le i\le 8) is i-j.
For example, the name of the first stage is 1-1, and the name of the last stage is 8-8.
Given the stage name S of the stage Takahashi is currently playing, output the stage name of the next stage.
Constraints
- S is the stage name of one of the stages.
- S is not
8-8.
Input
The input is given from Standard Input in the following format:
S
Output
Output the stage name of the next stage.
Sample Input 1
4-2
Sample Output 1
4-3
The next stage after the 2nd stage in the 4th world is the 3rd stage in the same world.
Sample Input 2
1-8
Sample Output 2
2-1
1-8 is the last stage in the 1st world, so the next stage is the 1st stage in the 2nd world.
Sample Input 3
3-3
Sample Output 3
3-4
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
正整数 X が与えられます。
X を(先頭に 0 を含まない形で)十進表記した際に現れる数字を、先頭に 0 が来ないように 並び替えることで得られる正整数のうち、値が最小のものを求めてください。
制約
- 1\leq X < 10^5
- X は整数
入力
入力は以下の形式で標準入力から与えられる。
X
出力
答えを出力せよ。
入力例 1
903
出力例 1
309
X を十進表記した際に現れる数字を先頭に 0 が来ないように並び替えることで得られる正整数は、903, 930, 309, 390 の 4 通りであり、このうち値が最小のものは 309 です。
入力例 2
432
出力例 2
234
入力例 3
100
出力例 3
100
Score : 200 points
Problem Statement
You are given a positive integer X.
Find the minimum value among all positive integers that can be obtained by rearranging the digits appearing in the decimal representation of X (without leading zeros) such that there is no leading zero.
Constraints
- 1\leq X < 10^5
- X is an integer.
Input
The input is given from Standard Input in the following format:
X
Output
Output the answer.
Sample Input 1
903
Sample Output 1
309
There are four positive integers that can be obtained by rearranging the digits appearing in the decimal representation of X such that there is no leading zero: 903, 930, 309, 390; the minimum value among them is 309.
Sample Input 2
432
Sample Output 2
234
Sample Input 3
100
Sample Output 3
100
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 250 点
問題文
英小文字と ? からなる文字列 T と、英小文字のみからなる文字列 U が与えられます。
T は、英小文字のみからなる文字列 S のちょうど 4 文字を ? で置き換えることで得られた文字列です。
S が U を連続部分文字列として含んでいた可能性があるかどうか判定してください。
制約
- T は長さ 4 以上 10 以下の英小文字と
?からなる文字列 - T にはちょうど 4 つの
?が含まれる - U は長さ 1 以上 |T| 以下の英小文字からなる文字列
入力
入力は以下の形式で標準入力から与えられる。
T U
出力
S が U を部分文字列として含んでいた可能性があるならば Yes を、そうでないならば No を出力せよ。
入力例 1
tak??a?h? nashi
出力例 1
Yes
例えば、S が takanashi である場合、これは nashi を連続部分文字列として含みます。
入力例 2
??e??e snuke
出力例 2
No
? がどのような文字であっても、S は snuke を連続部分文字列として含むことがありません。
入力例 3
???? aoki
出力例 3
Yes
Score : 250 points
Problem Statement
You are given a string T consisting of lowercase English letters and ?, and a string U consisting of lowercase English letters.
The string T is obtained by taking some lowercase-only string S and replacing exactly four of its characters with ?.
Determine whether it is possible that the original string S contained U as a contiguous substring.
Constraints
- T is a string of length between 4 and 10, inclusive, consisting of lowercase letters and
?. - T contains exactly four occurrences of
?. - U is a string of length between 1 and |T|, inclusive, consisting of lowercase letters.
Input
The input is given from Standard Input in the following format:
T U
Output
Print Yes if it is possible that the original string S contained U as a contiguous substring; otherwise, print No.
Sample Input 1
tak??a?h? nashi
Sample Output 1
Yes
For example, if S is takanashi, it contains nashi as a contiguous substring.
Sample Input 2
??e??e snuke
Sample Output 2
No
No matter what characters replace the ?s in T, S cannot contain snuke as a contiguous substring.
Sample Input 3
???? aoki
Sample Output 3
Yes
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
N 個の餅が小さいほうから順に並んでいます。 i 番目 (1\leq i\leq N) の餅の大きさは A _ i です。
2 つの餅 A,B の大きさをそれぞれ a,b としたとき、a が b の半分以下であるとき、かつそのときに限り、餅 A を餅 B の上に乗せて鏡餅を 1 つ作ることができます。
N 個の餅から 2 つの餅を選び、一方をもう一方の上に乗せることで鏡餅を 1 つ作ります。
何種類の鏡餅を作ることができるか求めてください。
ただし、鏡餅を構成する餅の大きさが同じでも、少なくとも一方が異なる餅であれば別の種類の鏡餅として数えます。
制約
- 2\leq N\leq 5\times 10 ^ 5
- 1\leq A _ i\leq 10 ^ 9\ (1\leq i\leq N)
- A _ i\leq A _ {i+1}\ (1\leq i\lt N)
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N A _ 1 A _ 2 \cdots A _ N
出力
作ることができる鏡餅の種類数を出力せよ。
入力例 1
6 2 3 4 4 7 10
出力例 1
8
与えられた餅の大きさは以下のようになっています。

このとき、以下の 8 種類の鏡餅を作ることができます。

大きさ 4 の餅の上に大きさ 2 の餅を乗せた鏡餅や、大きさ 10 の餅の上に大きさ 4 の餅を乗せた鏡餅は 2 種類あることに注意してください。
入力例 2
3 387 388 389
出力例 2
0
鏡餅を 1 種類も作ることができない場合もあります。
入力例 3
32 1 2 4 5 8 10 12 16 19 25 33 40 50 64 87 101 149 175 202 211 278 314 355 405 412 420 442 481 512 582 600 641
出力例 3
388
Score : 300 points
Problem Statement
There are N mochi (rice cakes) arranged in ascending order of size. The size of the i-th mochi (1 \leq i \leq N) is A_i.
Given two mochi A and B, with sizes a and b respectively, you can make one kagamimochi (a stacked rice cake) by placing mochi A on top of mochi B if and only if a is at most half of b.
You choose two mochi out of the N mochi, and place one on top of the other to form one kagamimochi.
Find how many different kinds of kagamimochi can be made.
Two kagamimochi are distinguished if at least one of the mochi is different, even if the sizes of the mochi are the same.
Constraints
- 2 \leq N \leq 5 \times 10^5
- 1 \leq A_i \leq 10^9 \ (1 \leq i \leq N)
- A_i \leq A_{i+1} \ (1 \leq i < 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
Print the number of different kinds of kagamimochi that can be made.
Sample Input 1
6 2 3 4 4 7 10
Sample Output 1
8
The sizes of the given mochi are as follows:

In this case, you can make the following eight kinds of kagamimochi:

Note that there are two kinds of kagamimochi where a mochi of size 4 is topped by a mochi of size 2, and two kinds where a mochi of size 10 is topped by a mochi of size 4.
Sample Input 2
3 387 388 389
Sample Output 2
0
It is possible that you cannot make any kagamimochi.
Sample Input 3
32 1 2 4 5 8 10 12 16 19 25 33 40 50 64 87 101 149 175 202 211 278 314 355 405 412 420 442 481 512 582 600 641
Sample Output 3
388