実行時間制限: 2 sec / メモリ制限: 1024 MB
配点 : 100 点
問題文
ビスケット生産装置を起動すると、起動してから A 秒後、2A 秒後、3A 秒後、... (A の倍数秒後) に B 枚ずつビスケットを生産します。
ビスケット生産装置を起動してから T + 0.5 秒後までに生産されるビスケットの合計枚数を求めてください。
制約
- 入力は全て整数である。
- 1 \leq A, B, T \leq 20
入力
入力は以下の形式で標準入力から与えられる。
A B T
出力
ビスケット生産装置を起動してから T + 0.5 秒後までに生産されるビスケットの合計枚数を出力せよ。
入力例 1
3 5 7
出力例 1
10
- ビスケット生産装置を起動してから 3 秒後に 5 枚のビスケットが生産されます。
- ビスケット生産装置を起動してから 6 秒後に 5 枚のビスケットが生産されます。
- したがって、ビスケット生産装置を起動してから 7.5 秒後までに合計 10 枚のビスケットが生産されます。
入力例 2
3 2 9
出力例 2
6
入力例 3
20 20 19
出力例 3
0
Score : 100 points
Problem Statement
A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.
Find the total number of biscuits produced within T + 0.5 seconds after activation.
Constraints
- All values in input are integers.
- 1 \leq A, B, T \leq 20
Input
Input is given from Standard Input in the following format:
A B T
Output
Print the total number of biscuits produced within T + 0.5 seconds after activation.
Sample Input 1
3 5 7
Sample Output 1
10
- Five biscuits will be produced three seconds after activation.
- Another five biscuits will be produced six seconds after activation.
- Thus, a total of ten biscuits will be produced within 7.5 seconds after activation.
Sample Input 2
3 2 9
Sample Output 2
6
Sample Input 3
20 20 19
Sample Output 3
0
実行時間制限: 2 sec / メモリ制限: 1024 MB
配点 : 200 点
問題文
N 個の宝石があり、i 番目の宝石の価値は V_i です。
あなたはこれらの宝石の中からいくつかを選んで手に入れます。
このとき、1 つも選ばなくとも、全て選んでも構いません。
ただし、i 番目の宝石を手に入れる場合コスト C_i を支払わなければいけません。
手に入れた宝石の価値の合計を X、支払ったコストの合計を Y とします。
X-Y の最大値を求めてください。
制約
- 入力は全て整数である。
- 1 \leq N \leq 20
- 1 \leq C_i, V_i \leq 50
入力
入力は以下の形式で標準入力から与えられる。
N V_1 V_2 ... V_N C_1 C_2 ... C_N
出力
X-Y の最大値を出力せよ。
入力例 1
3 10 2 5 6 3 4
出力例 1
5
1 番目の宝石と 3 番目の宝石を選んだとき、X = 10 + 5 = 15, Y = 6 + 4 = 10 です。 このとき、X-Y = 5 となり、これが最大です。
入力例 2
4 13 21 6 19 11 30 6 15
出力例 2
6
入力例 3
1 1 50
出力例 3
0
Score : 200 points
Problem Statement
There are N gems. The value of the i-th gem is V_i.
You will choose some of these gems, possibly all or none, and get them.
However, you need to pay a cost of C_i to get the i-th gem.
Let X be the sum of the values of the gems obtained, and Y be the sum of the costs paid.
Find the maximum possible value of X-Y.
Constraints
- All values in input are integers.
- 1 \leq N \leq 20
- 1 \leq C_i, V_i \leq 50
Input
Input is given from Standard Input in the following format:
N V_1 V_2 ... V_N C_1 C_2 ... C_N
Output
Print the maximum possible value of X-Y.
Sample Input 1
3 10 2 5 6 3 4
Sample Output 1
5
If we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10. We have X-Y = 5 here, which is the maximum possible value.
Sample Input 2
4 13 21 6 19 11 30 6 15
Sample Output 2
6
Sample Input 3
1 1 50
Sample Output 3
0
実行時間制限: 2 sec / メモリ制限: 1024 MB
配点 : 300 点
問題文
N 個の整数 A_1, A_2, ..., A_N が黒板に書かれています。
あなたはこの中から整数を 1 つ選んで、1 以上 10^9 以下の好きな整数に書き換えます。
元の整数と同じ整数に書き換えても構いません。
書き換えた後の N 個の整数の最大公約数の最大値を求めてください。
制約
- 入力は全て整数である。
- 2 \leq N \leq 10^5
- 1 \leq A_i \leq 10^9
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 ... A_N
出力
書き換えた後の N 個の整数の最大公約数の最大値を出力せよ。
入力例 1
3 7 6 8
出力例 1
2
7 を 4 に書き換えると 3 つの整数の最大公約数は 2 となり、これが最大です。
入力例 2
3 12 15 18
出力例 2
6
入力例 3
2 1000000000 1000000000
出力例 3
1000000000
元の整数と同じ整数に書き換えることも可能です。
Score : 300 points
Problem Statement
There are N integers, A_1, A_2, ..., A_N, written on the blackboard.
You will choose one of them and replace it with an integer of your choice between 1 and 10^9 (inclusive), possibly the same as the integer originally written.
Find the maximum possible greatest common divisor of the N integers on the blackboard after your move.
Constraints
- All values in input are integers.
- 2 \leq N \leq 10^5
- 1 \leq A_i \leq 10^9
Output
Input is given from Standard Input in the following format:
N A_1 A_2 ... A_N
Output
Print the maximum possible greatest common divisor of the N integers on the blackboard after your move.
Sample Input 1
3 7 6 8
Sample Output 1
2
If we replace 7 with 4, the greatest common divisor of the three integers on the blackboard will be 2, which is the maximum possible value.
Sample Input 2
3 12 15 18
Sample Output 2
6
Sample Input 3
2 1000000000 1000000000
Sample Output 3
1000000000
We can replace an integer with itself.
実行時間制限: 2 sec / メモリ制限: 1024 MB
配点 : 400 点
問題文
N 個の整数が並んでおり、順に A_1, A_2, ..., A_N です。
あなたはこの整数列に対して次の操作を好きなだけ行うことができます。
操作: 1 \leq i \leq N-1 を満たす整数 i を選ぶ。A_i と A_{i+1} に -1 を乗算する。
操作終了後の整数列を B_1, B_2, ..., B_N とします。
B_1 + B_2 + ... + B_N の最大値を求めてください。
制約
- 入力は全て整数である。
- 2 \leq N \leq 10^5
- -10^9 \leq A_i \leq 10^9
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 ... A_N
出力
B_1 + B_2 + ... + B_N の最大値を出力せよ。
入力例 1
3 -10 5 -4
出力例 1
19
次のように操作を行うと、B_1 = 10, B_2 = 5, B_3 = 4 になり、このときの B_1 + B_2 + B_3 = 10 + 5 + 4 = 19 が最大です。
- i として 1 を選ぶ。操作により、整数列は 10, -5, -4 に変化する。
- i として 2 を選ぶ。操作により、整数列は 10, 5, 4 に変化する。
入力例 2
5 10 -4 -8 -11 3
出力例 2
30
入力例 3
11 -1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
出力例 3
10000000000
出力が 32 ビット整数型に収まらない場合があります。
Score : 400 points
Problem Statement
There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.
You can perform the following operation on this integer sequence any number of times:
Operation: Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.
Let B_1, B_2, ..., B_N be the integer sequence after your operations.
Find the maximum possible value of B_1 + B_2 + ... + B_N.
Constraints
- All values in input are integers.
- 2 \leq N \leq 10^5
- -10^9 \leq A_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N A_1 A_2 ... A_N
Output
Print the maximum possible value of B_1 + B_2 + ... + B_N.
Sample Input 1
3 -10 5 -4
Sample Output 1
19
If we perform the operation as follows:
- Choose 1 as i, which changes the sequence to 10, -5, -4.
- Choose 2 as i, which changes the sequence to 10, 5, 4.
we have B_1 = 10, B_2 = 5, B_3 = 4. The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19, is the maximum possible result.
Sample Input 2
5 10 -4 -8 -11 3
Sample Output 2
30
Sample Input 3
11 -1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000
Sample Output 3
10000000000
The output may not fit into a 32-bit integer type.