Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
円周率の小数第 100 位までの値は
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
です。
1 以上 100 以下の整数 N が与えられます。
円周率を小数第 N 位まで出力してください。
より厳密には、円周率を小数第 N+1 位で切り捨て、末尾の 0
を取り除かずに出力してください。
制約
- 1\leq N\leq 100
- N は整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
円周率を小数第 N 位まで 1 行で出力せよ。
入力例 1
2
出力例 1
3.14
円周率を小数第 2+1 位で切り捨てると値は 3.14
になります。
よって、3.14
を出力してください。
入力例 2
32
出力例 2
3.14159265358979323846264338327950
末尾の 0
は取り除かずに出力してください。
入力例 3
100
出力例 3
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
Score : 100 points
Problem Statement
The number pi to the 100-th decimal place is
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
.
You are given an integer N between 1 and 100, inclusive.
Print the value of pi to the N-th decimal place.
More precisely, truncate the value of pi to N decimal places and print the result without removing the trailing 0
s.
Constraints
- 1\leq N\leq 100
- N is an integer.
Input
The input is given from Standard Input in the following format:
N
Output
Print the value of pi to the N-th decimal place in a single line.
Sample Input 1
2
Sample Output 1
3.14
Truncating the value of pi to 2 decimal places results in 3.14
. Thus, you should print 3.14
.
Sample Input 2
32
Sample Output 2
3.14159265358979323846264338327950
Do not remove the trailing 0
s.
Sample Input 3
100
Sample Output 3
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
2^n \gt n^2 ですか?
制約
- n は 1 以上 10^9 以下の整数
入力
入力は以下の形式で標準入力から与えられる。
n
出力
2^n \gt n^2 なら Yes
を、そうでないなら No
を出力せよ。
入力例 1
5
出力例 1
Yes
2^5=32,\ 5^2=25 より 2^n \gt n^2 であるため、Yes
を出力します。
入力例 2
2
出力例 2
No
n=2 の場合 2^n=n^2=2^2 となり、故に 2^n \gt n^2 ではありません。よって No
を出力します。
入力例 3
623947744
出力例 3
Yes
Score : 100 points
Problem Statement
Does 2^n \gt n^2 hold?
Constraints
- n is an integer between 1 and 10^9 (inclusive).
Input
Input is given from Standard Input in the following format:
n
Output
If 2^n \gt n^2, print Yes
; otherwise, print No
.
Sample Input 1
5
Sample Output 1
Yes
Since 2^5=32,\ 5^2=25, we have 2^n \gt n^2, so Yes
should be printed.
Sample Input 2
2
Sample Output 2
No
For n=2, we have 2^n=n^2=2^2, so 2^n \gt n^2 does not hold. Thus, No
should be printed.
Sample Input 3
623947744
Sample Output 3
Yes
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
英小文字からなる文字列 S,T が与えられるので、 T が S の(連続する)部分文字列かどうか判定してください。
なお、文字列 X に以下の操作を 0 回以上施して文字列 Y が得られる時、またその時に限り Y は X の(連続する)部分文字列であると言います。
- 以下の 2 つの操作から 1 つを選択して、その操作を行う。
- X の先頭の 1 文字を削除する。
- X の末尾の 1 文字を削除する。
例えば tag
は voltage
の(連続する)部分文字列ですが、 ace
は atcoder
の(連続する)部分文字列ではありません。
制約
- S,T は英小文字からなる
- 1 \le |S|,|T| \le 100 ( |X| は文字列 X の長さ )
入力
入力は以下の形式で標準入力から与えられる。
S T
出力
T が S の(連続する)部分文字列なら Yes
、そうでないなら No
と出力せよ。
入力例 1
voltage tag
出力例 1
Yes
tag
は voltage
の(連続する)部分文字列です。
入力例 2
atcoder ace
出力例 2
No
ace
は atcoder
の(連続する)部分文字列ではありません。
入力例 3
gorilla gorillagorillagorilla
出力例 3
No
入力例 4
toyotasystems toyotasystems
出力例 4
Yes
S=T である場合もあります。
Score : 200 points
Problem Statement
You are given strings S and T consisting of lowercase English letters. Determine whether T is a (contiguous) substring of S.
A string Y is said to be a (contiguous) substring of X if and only if Y can be obtained by performing the operation below on X zero or more times.
- Do one of the following.
- Delete the first character in X.
- Delete the last character in X.
For instance, tag
is a (contiguous) substring of voltage
, while ace
is not a (contiguous) substring of atcoder
.
Constraints
- S and T consist of lowercase English letters.
- 1 \le |S|,|T| \le 100 (|X| denotes the length of a string X.)
Input
The input is given from Standard Input in the following format:
S T
Output
If T is a (contiguous) substring of S, print Yes
; otherwise, print No
.
Sample Input 1
voltage tag
Sample Output 1
Yes
tag
is a (contiguous) substring of voltage
.
Sample Input 2
atcoder ace
Sample Output 2
No
ace
is not a (contiguous) substring of atcoder
.
Sample Input 3
gorilla gorillagorillagorilla
Sample Output 3
No
Sample Input 4
toyotasystems toyotasystems
Sample Output 4
Yes
It is possible that S=T.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
非負整数 A,B,C,D,E,F があり、A\times B\times C\geq D\times E\times F をみたしています。
(A\times B\times C)-(D\times E\times F) の値を 998244353 で割った余りを求めてください。
制約
- 0\leq A,B,C,D,E,F\leq 10^{18}
- A\times B\times C\geq D\times E\times F
- A,B,C,D,E,F は整数
入力
入力は以下の形式で標準入力から与えられる。
A B C D E F
出力
(A\times B\times C)-(D\times E\times F) を 998244353 で割った余りを整数で出力せよ。
入力例 1
2 3 5 1 2 4
出力例 1
22
A\times B\times C=2\times 3\times 5=30, D\times E\times F=1\times 2\times 4=8 より、
(A\times B\times C)-(D\times E\times F)=22 であり、これを 998244353 で割った余りである 22 を出力します。
入力例 2
1 1 1000000000 0 0 0
出力例 2
1755647
A\times B\times C=1000000000, D\times E\times F=0 より、
(A\times B\times C)-(D\times E\times F)=1000000000 であり、これを 998244353 で割った余りである 1755647 を出力します。
入力例 3
1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000
出力例 3
0
(A\times B\times C)-(D\times E\times F)=0 であり、これを 998244353 で割った余りである 0 を出力します。
Score : 200 points
Problem Statement
There are non-negative integers A, B, C, D, E, and F, which satisfy A\times B\times C\geq D\times E\times F.
Find the remainder when (A\times B\times C)-(D\times E\times F) is divided by 998244353.
Constraints
- 0\leq A,B,C,D,E,F\leq 10^{18}
- A\times B\times C\geq D\times E\times F
- A, B, C, D, E, and F are integers.
Input
The input is given from Standard Input in the following format:
A B C D E F
Output
Print the remainder when (A\times B\times C)-(D\times E\times F) is divided by 998244353, as an integer.
Sample Input 1
2 3 5 1 2 4
Sample Output 1
22
Since A\times B\times C=2\times 3\times 5=30 and D\times E\times F=1\times 2\times 4=8,
we have (A\times B\times C)-(D\times E\times F)=22. Divide this by 998244353 and print the remainder, which is 22.
Sample Input 2
1 1 1000000000 0 0 0
Sample Output 2
1755647
Since A\times B\times C=1000000000 and D\times E\times F=0,
we have (A\times B\times C)-(D\times E\times F)=1000000000. Divide this by 998244353 and print the remainder, which is 1755647.
Sample Input 3
1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000
Sample Output 3
0
We have (A\times B\times C)-(D\times E\times F)=0. Divide this by 998244353 and print the remainder, which is 0.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
ピザ屋で働く高橋くんは、まかないとして美味しいチーズピザを作ることにしました。
今、高橋くんの目の前に N 種類のチーズがあります。
i 種類目のチーズは 1 [g] あたりのおいしさが A_i で、 B_i [g] あります。
ピザのおいしさは、ピザに乗せたチーズのおいしさの総和で決まります。
但し、チーズを使いすぎると怒られてしまうため、乗せたチーズの重さは合計で W [g] 以下である必要があります。
この条件のもとで、可能なピザのおいしさの最大値を求めてください。
制約
- 入力は全て整数
- 1 \le N \le 3 \times 10^5
- 1 \le W \le 3 \times 10^8
- 1 \le A_i \le 10^9
- 1 \le B_i \le 1000
入力
入力は以下の形式で標準入力から与えられる。
N W A_1 B_1 A_2 B_2 \vdots A_N B_N
出力
答えを整数として出力せよ。
入力例 1
3 5 3 1 4 2 2 3
出力例 1
15
1 種類目のチーズを 1 [g] 、 2 種類目のチーズを 2 [g] 、 3 種類目のチーズを 2 [g] 乗せるのが最適です。
このとき、ピザのおいしさは 15 となります。
入力例 2
4 100 6 2 1 5 3 9 8 7
出力例 2
100
チーズの重量の総和が W [g] に満たないケースもあります。
入力例 3
10 3141 314944731 649 140276783 228 578012421 809 878510647 519 925326537 943 337666726 611 879137070 306 87808915 39 756059990 244 228622672 291
出力例 3
2357689932073
Score : 300 points
Problem Statement
Takahashi, who works for a pizza restaurant, is making a delicious cheese pizza for staff meals.
There are N kinds of cheese in front of him.
The deliciousness of the i-th kind of cheese is A_i per gram, and B_i grams of this cheese are available.
The deliciousness of the pizza will be the total deliciousness of cheese he puts on top of the pizza.
However, using too much cheese would make his boss angry, so the pizza can have at most W grams of cheese on top of it.
Under this condition, find the maximum possible deliciousness of the pizza.
Constraints
- All values in input are integers.
- 1 \le N \le 3 \times 10^5
- 1 \le W \le 3 \times 10^8
- 1 \le A_i \le 10^9
- 1 \le B_i \le 1000
Input
Input is given from Standard Input in the following format:
N W A_1 B_1 A_2 B_2 \vdots A_N B_N
Output
Print the answer as an integer.
Sample Input 1
3 5 3 1 4 2 2 3
Sample Output 1
15
The optimal choice is to use 1 gram of cheese of the first kind, 2 grams of the second kind, and 2 grams of the third kind.
The pizza will have a deliciousness of 15.
Sample Input 2
4 100 6 2 1 5 3 9 8 7
Sample Output 2
100
There may be less than W grams of cheese in total.
Sample Input 3
10 3141 314944731 649 140276783 228 578012421 809 878510647 519 925326537 943 337666726 611 879137070 306 87808915 39 756059990 244 228622672 291
Sample Output 3
2357689932073