A - 753

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 100

問題文

七五三とは、7 歳、5 歳そして 3 歳の子どもの成長を祝うとある国の行事です。

いま、高橋くんは X 歳です。今回の七五三で、高橋くんの成長は祝われるでしょうか?

制約

  • 1 ≤ X ≤ 9
  • X は整数である。

入力

入力は以下の形式で標準入力から与えられる。

X

出力

高橋くんの成長が祝われるなら YES, 祝われないなら NO と出力せよ。


入力例 1

5

出力例 1

YES

5 歳の子どもの成長は祝われます。


入力例 2

6

出力例 2

NO

また来年。

Score : 100 points

Problem Statement

Shichi-Go-San (literally "Seven-Five-Three") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.

Takahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?

Constraints

  • 1 ≤ X ≤ 9
  • X is an integer.

Input

Input is given from Standard Input in the following format:

X

Output

If Takahashi's growth will be celebrated, print YES; if it will not, print NO.


Sample Input 1

5

Sample Output 1

YES

The growth of a five-year-old child will be celebrated.


Sample Input 2

6

Sample Output 2

NO

See you next year.

B - 754

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 200

問題文

数字 1, 2, ..., 9 からなる文字列 S があります。 ダックスフンドのルンルンは、S から連続する 3 個の数字を取り出し、 1 つの整数 X としてご主人様の元に持っていきます。(数字の順番を変えることはできません。)

ご主人様が大好きな数は 753 で、これに近い数ほど好きです。 X753 の差(の絶対値)は最小でいくつになるでしょうか?

制約

  • S は長さ 4 以上 10 以下の文字列である。
  • S の各文字は 1, 2, ..., 9 のいずれかである。

入力

入力は以下の形式で標準入力から与えられる。

S

出力

X753 の差としてありうる最小値を出力せよ。


入力例 1

1234567876

出力例 1

34

7 文字目から 9 文字目までを取り出すと X = 787 となり、これと 753 との差は 787 - 753 = 34 です。X をどこから取り出しても、差をより小さくすることはできません。

なお、数字の順番を変えることはできません。例えば、567 を取り出して 765 に並び変えてはいけません。

また、S から連続していない 3 文字を取り出すこともできません。例えば、7 文字目の 79 文字目の 710 文字目の 6 を取り出して 776 としてはいけません。


入力例 2

35753

出力例 2

0

753 そのものを取り出すことができる場合、答えは 0 です。


入力例 3

1111111111

出力例 3

642

どこから 3 文字を取り出しても X = 111 となり、差は 753 - 111 = 642 です。

Score : 200 points

Problem Statement

There is a string S consisting of digits 1, 2, ..., 9. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)

The master's favorite number is 753. The closer to this number, the better. What is the minimum possible (absolute) difference between X and 753?

Constraints

  • S is a string of length between 4 and 10 (inclusive).
  • Each character in S is 1, 2, ..., or 9.

Input

Input is given from Standard Input in the following format:

S

Output

Print the minimum possible difference between X and 753.


Sample Input 1

1234567876

Sample Output 1

34

Taking out the seventh to ninth characters results in X = 787, and the difference between this and 753 is 787 - 753 = 34. The difference cannot be made smaller, no matter where X is taken from.

Note that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.

We cannot take out three digits that are not consecutive from S, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.


Sample Input 2

35753

Sample Output 2

0

If 753 itself can be taken out, the answer is 0.


Sample Input 3

1111111111

Sample Output 3

642

No matter where X is taken from, X = 111, with the difference 753 - 111 = 642.

C - 755

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 300

問題文

整数 N が与えられます。1 以上 N 以下の整数のうち、七五三数 は何個あるでしょうか?

ここで、七五三数とは以下の条件を満たす正の整数です。

  • 十進法で表記したとき、数字 7, 5, 3 がそれぞれ 1 回以上現れ、これら以外の数字は現れない。

制約

  • 1 \leq N < 10^9
  • N は整数である。

入力

入力は以下の形式で標準入力から与えられる。

N

出力

1 以上 N 以下の七五三数の個数を出力せよ。


入力例 1

575

出力例 1

4

575 以下の七五三数は、357, 375, 537, 5734 個です。


入力例 2

3600

出力例 2

13

3600 以下の七五三数は、上記の 4 個と 735, 753, 3357, 3375, 3537, 3557, 3573, 3575, 3577 の計 13 個です。


入力例 3

999999999

出力例 3

26484

Score : 300 points

Problem Statement

You are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally "Seven-Five-Three numbers") are there?

Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:

  • When the number is written in base ten, each of the digits 7, 5 and 3 appears at least once, and the other digits never appear.

Constraints

  • 1 \leq N < 10^9
  • N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of the Shichi-Go-San numbers between 1 and N (inclusive).


Sample Input 1

575

Sample Output 1

4

There are four Shichi-Go-San numbers not greater than 575: 357, 375, 537 and 573.


Sample Input 2

3600

Sample Output 2

13

There are 13 Shichi-Go-San numbers not greater than 3600: the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577.


Sample Input 3

999999999

Sample Output 3

26484
D - 756

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 400

問題文

整数 N が与えられます。N! (= 1 \times 2 \times ... \times N) の約数のうち、七五数 は何個あるでしょうか?

ここで、七五数とは約数をちょうど 75 個持つ正の整数です。

注記

正の整数 A が正の整数 B を割り切るとき、AB約数 といいます。 例えば、6 の約数は 1,2,3,64 個です。

制約

  • 1 \leq N \leq 100
  • N は整数である。

入力

入力は以下の形式で標準入力から与えられる。

N

出力

N! の約数であるような七五数の個数を出力せよ。


入力例 1

9

出力例 1

0

9! = 1 \times 2 \times ... \times 9 = 362880 の約数に七五数はありません。


入力例 2

10

出力例 2

1

10! = 3628800 の約数のうち、七五数であるのは 324001 個です。


入力例 3

100

出力例 3

543

Score : 400 points

Problem Statement

You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ... \times N), how many Shichi-Go numbers (literally "Seven-Five numbers") are there?

Here, a Shichi-Go number is a positive integer that has exactly 75 divisors.

Note

When a positive integer A divides a positive integer B, A is said to a divisor of B. For example, 6 has four divisors: 1, 2, 3 and 6.

Constraints

  • 1 \leq N \leq 100
  • N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of the Shichi-Go numbers that are divisors of N!.


Sample Input 1

9

Sample Output 1

0

There are no Shichi-Go numbers among the divisors of 9! = 1 \times 2 \times ... \times 9 = 362880.


Sample Input 2

10

Sample Output 2

1

There is one Shichi-Go number among the divisors of 10! = 3628800: 32400.


Sample Input 3

100

Sample Output 3

543