Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 100 点
問題文
二つの長方形があります。 一つ目の長方形は、縦の辺の長さが A、横の辺の長さが B です。 二つ目の長方形は、縦の辺の長さが C、横の辺の長さが D です。
この二つの長方形のうち、面積の大きい方の面積を出力してください。 なお、二つの長方形の面積が等しい時は、その面積を出力してください。
制約
- 入力は全て整数である
- 1≦A≦10^4
- 1≦B≦10^4
- 1≦C≦10^4
- 1≦D≦10^4
入力
入力は以下の形式で標準入力から与えられる。
A B C D
出力
大きい方の長方形の面積を出力せよ。 二つの長方形の面積が等しいなら、その面積を出力せよ。
入力例 1
3 5 2 7
出力例 1
15
一つ目の長方形の面積は 3×5=15 で、二つ目の長方形の面積は 2×7=14 です。 よって、大きい方の面積である 15 を出力します。
入力例 2
100 600 200 300
出力例 2
60000
どちらの長方形の面積も 60000 なので、60000 を出力します。
Score : 100 points
Problem Statement
There are two rectangles. The lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B. The lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D.
Print the area of the rectangle with the larger area. If the two rectangles have equal areas, print that area.
Constraints
- All input values are integers.
- 1≤A≤10^4
- 1≤B≤10^4
- 1≤C≤10^4
- 1≤D≤10^4
Input
The input is given from Standard Input in the following format:
A B C D
Output
Print the area of the rectangle with the larger area. If the two rectangles have equal areas, print that area.
Sample Input 1
3 5 2 7
Sample Output 1
15
The first rectangle has an area of 3×5=15, and the second rectangle has an area of 2×7=14. Thus, the output should be 15, the larger area.
Sample Input 2
100 600 200 300
Sample Output 2
60000
Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 200 点
問題文
あなたは整数 x を持っています。 最初、x=0 です。
あなたは、長さ N の文字列 S をもらったので、これを使って N 回の操作を行いました。
i 回目の操作では、S_i=I
ならば x の値を 1 増やし、S_i=D
ならば x の値を 1 減らしました。
操作の途中( 1 回目の操作の前、N 回目の操作の後も含む)で x がとる値の最大値を答えてください。
制約
- 1≦N≦100
- |S|=N
- S には、
I
、D
以外の文字は含まれない
入力
入力は以下の形式で標準入力から与えられる。
N S
出力
操作の途中での整数 x がとる値の最大値を出力せよ。
入力例 1
5 IIDID
出力例 1
2
それぞれの操作後の x の値は、1,2,1,2,1 となるので、最大値である 2 を出力します。
入力例 2
7 DDIDDII
出力例 2
0
最初の x=0 の状態で x が最大になるので、0 を出力します。
Score : 200 points
Problem Statement
You have an integer variable x. Initially, x=0.
Some person gave you a string S of length N, and using the string you performed the following operation N times.
In the i-th operation, you incremented the value of x by 1 if S_i=I
, and decremented the value of x by 1 if S_i=D
.
Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
Constraints
- 1≤N≤100
- |S|=N
- No characters except
I
andD
occur in S.
Input
The input is given from Standard Input in the following format:
N S
Output
Print the maximum value taken by x during the operations.
Sample Input 1
5 IIDID
Sample Output 1
2
After each operation, the value of x becomes 1, 2, 1, 2 and 1, respectively. Thus, the output should be 2, the maximum value.
Sample Input 2
7 DDIDDII
Sample Output 2
0
The initial value x=0 is the maximum value taken by x, thus the output should be 0.
Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 300 点
問題文
整数 N が与えられます。 N! の正の約数の個数を 10^9+7 で割った余りを求めてください。
制約
- 1≦N≦10^3
入力
入力は以下の形式で標準入力から与えられる。
N
出力
N! の正の約数の個数を 10^9+7 で割った余りを出力せよ。
入力例 1
3
出力例 1
4
3! =6 です。6 の正の約数は 1,2,3,6 の 4 個なので、4 を出力します。
入力例 2
6
出力例 2
30
入力例 3
1000
出力例 3
972926972
Score : 300 points
Problem Statement
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.
Constraints
- 1≤N≤10^3
Input
The input is given from Standard Input in the following format:
N
Output
Print the number of the positive divisors of N!, modulo 10^9+7.
Sample Input 1
3
Sample Output 1
4
There are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.
Sample Input 2
6
Sample Output 2
30
Sample Input 3
1000
Sample Output 3
972926972
Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 500 点
問題文
東西方向にのびる直線上に、N 個の町があります。 町には、西から順に 1 から N までの番号がついています。 直線上には座標が設定されていて、東に行くほど座標が大きくなります。 町 i の座標は X_i です。
あなたは今、町 1 にいて、これからほかの全ての町を訪れたいです。 移動する手段は次の 2 種類あります。
-
直線上を歩いて移動する。 東西どちらに歩いても、1 移動する度に疲労度が A 上がります。
-
好きな場所へテレポートする。 テレポートをすると、移動した距離によらず疲労度が B 上がります。
この 2 種類の移動を繰り返して全ての町を最適に回った時、疲労度の上昇値の合計の最小値がいくつになるか求めてください。
制約
- 入力は全て整数である
- 2≦N≦10^5
- 1≦X_i≦10^9
- 全ての i(1≦i≦N-1) について、X_i<X_{i+1} が成り立つ
- 1≦A≦10^9
- 1≦B≦10^9
入力
入力は以下の形式で標準入力から与えられる。
N A B X_1 X_2 ... X_N
出力
全ての町を最適に回った時、疲労度の上昇値の合計の最小値がいくつになるかを出力せよ。
入力例 1
4 2 5 1 2 5 7
出力例 1
11
町 1 から町 2 まで 1 の距離歩いて移動したあと、町 3 にテレポートし、そこから町 4 まで 2 の距離歩いて移動すると、 疲労度の上昇値の合計が 2×1+5+2×2=11 になり、これが最小です。
入力例 2
7 1 100 40 43 45 105 108 115 124
出力例 2
84
町 1 から町 7 まで歩き続けると、疲労度の上昇値の合計が 84 になり、これが最小です。
入力例 3
7 1 2 24 35 40 68 72 99 103
出力例 3
12
どのような順番でもよいので、6 回のテレポートで全ての町を訪れると、疲労度の上昇値の合計が 12 になり、これが最小です。
Score : 500 points
Problem Statement
There are N towns on a line running east-west. The towns are numbered 1 through N, in order from west to east. Each point on the line has a one-dimensional coordinate, and a point that is farther east has a greater coordinate value. The coordinate of town i is X_i.
You are now at town 1, and you want to visit all the other towns. You have two ways to travel:
-
Walk on the line. Your fatigue level increases by A each time you travel a distance of 1, regardless of direction.
-
Teleport to any location of your choice. Your fatigue level increases by B, regardless of the distance covered.
Find the minimum possible total increase of your fatigue level when you visit all the towns in these two ways.
Constraints
- All input values are integers.
- 2≤N≤10^5
- 1≤X_i≤10^9
- For all i(1≤i≤N-1), X_i<X_{i+1}.
- 1≤A≤10^9
- 1≤B≤10^9
Input
The input is given from Standard Input in the following format:
N A B X_1 X_2 ... X_N
Output
Print the minimum possible total increase of your fatigue level when you visit all the towns.
Sample Input 1
4 2 5 1 2 5 7
Sample Output 1
11
From town 1, walk a distance of 1 to town 2, then teleport to town 3, then walk a distance of 2 to town 4. The total increase of your fatigue level in this case is 2×1+5+2×2=11, which is the minimum possible value.
Sample Input 2
7 1 100 40 43 45 105 108 115 124
Sample Output 2
84
From town 1, walk all the way to town 7. The total increase of your fatigue level in this case is 84, which is the minimum possible value.
Sample Input 3
7 1 2 24 35 40 68 72 99 103
Sample Output 3
12
Visit all the towns in any order by teleporting six times. The total increase of your fatigue level in this case is 12, which is the minimum possible value.