A - Hamming Distance

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 100

問題文

正整数 N および、英小文字からなる長さ N の文字列 S,T が与えられます。

ST のハミング距離を求めてください。 すなわち、1 以上 N 以下の整数 i であって、Si 文字目と Ti 文字目が異なるようなものの個数を求めてください。

制約

  • 1\leq N \leq 100
  • N は整数
  • S,T はそれぞれ英小文字からなる長さ N の文字列

入力

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

N
S
T

出力

答えを出力せよ。


入力例 1

6
abcarc
agcahc

出力例 1

2

ST2,5 文字目が異なり、それ以外が等しいです。よって答えは 2 です。


入力例 2

7
atcoder
contest

出力例 2

7

入力例 3

8
chokudai
chokudai

出力例 3

0

入力例 4

10
vexknuampx
vzxikuamlx

出力例 4

4

Score : 100 points

Problem Statement

You are given a positive integer N and two strings S and T, each of length N and consisting of lowercase English letters.

Find the Hamming distance between S and T. That is, find the number of integers i such that 1 \leq i \leq N and the i-th character of S is different from the i-th character of T.

Constraints

  • 1\leq N \leq 100
  • N is an integer.
  • Each of S and T is a string of length N consisting of lowercase English letters.

Input

The input is given from Standard Input in the following format:

N
S
T

Output

Print the answer.


Sample Input 1

6
abcarc
agcahc

Sample Output 1

2

S and T differ in the 2nd and 5th characters, but not in other characters. Thus, the answer is 2.


Sample Input 2

7
atcoder
contest

Sample Output 2

7

Sample Input 3

8
chokudai
chokudai

Sample Output 3

0

Sample Input 4

10
vexknuampx
vzxikuamlx

Sample Output 4

4
B - Weak Beats

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 100

問題文

01 からなる長さ 16 の文字列 S が与えられます。

2 以上 16 以下のすべての偶数 i について Si 文字目が 0 ならば Yes を、 そうでないならば No を出力してください。

制約

  • S01 からなる長さ 16 の文字列

入力

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

S

出力

2 以上 16 以下のすべての偶数 i について Si 文字目が 0 ならば Yes を、 そうでないならば No を出力せよ。


入力例 1

1001000000001010

出力例 1

No

S= 10010000000010104 文字目が 1 であるため、No を出力します。


入力例 2

1010100000101000

出力例 2

Yes

S= 1010100000101000 の偶数番目の文字はすべて 0 であるため、Yes を出力します。


入力例 3

1111111111111111

出力例 3

No

S の偶数文字目はすべて 1 となっています。 特に「すべて 0 」ではないため、No を出力します。

Score : 100 points

Problem Statement

You are given a string S of length 16 consisting of 0 and 1.

If the i-th character of S is 0 for every even number i from 2 through 16, print Yes; otherwise, print No.

Constraints

  • S is a string of length 16 consisting of 0 and 1.

Input

The input is given from Standard Input in the following format:

S

Output

If the i-th character of S is 0 for every even number i from 2 through 16, print Yes; otherwise, print No.


Sample Input 1

1001000000001010

Sample Output 1

No

The 4-th character of S= 1001000000001010 is 1, so you should print No.


Sample Input 2

1010100000101000

Sample Output 2

Yes

Every even-positioned character in S= 1010100000101000 is 0, so you should print Yes.


Sample Input 3

1111111111111111

Sample Output 3

No

Every even-positioned character in S is 1. Particularly, they are not all 0, so you should print No.

C - Base 2

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 200

問題文

01 からなる長さ 64 の数列 A=(A_0,A_1,\dots,A_{63}) が与えられます。

A_0 2^0 + A_1 2^1 + \dots + A_{63} 2^{63} を求めてください。

制約

  • A_i0 または 1

入力

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

A_0 A_1 \dots A_{63}

出力

答えを整数として出力せよ。


入力例 1

1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

出力例 1

13

A_0 2^0 + A_1 2^1 + \dots + A_{63} 2^{63} = 2^0 + 2^2 + 2^3 = 13 です。


入力例 2

1 0 1 0 1 0 0 0 0 1 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0 1 1 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 0 0 0 1 0 1 0 1 0 1 0 0 0 0

出力例 2

766067858140017173

Score : 200 points

Problem Statement

You are given a sequence A=(A_0,A_1,\dots,A_{63}) of length 64 consisting of 0 and 1.

Find A_0 2^0 + A_1 2^1 + \dots + A_{63} 2^{63}.

Constraints

  • A_i is 0 or 1.

Input

The input is given from Standard Input in the following format:

A_0 A_1 \dots A_{63}

Output

Print the answer as an integer.


Sample Input 1

1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Sample Output 1

13

A_0 2^0 + A_1 2^1 + \dots + A_{63} 2^{63} = 2^0 + 2^2 + 2^3 = 13.


Sample Input 2

1 0 1 0 1 0 0 0 0 1 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0 1 1 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 0 0 0 1 0 1 0 1 0 1 0 0 0 0

Sample Output 2

766067858140017173
D - tcaF

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 150

問題文

2 以上の整数 X が与えられます。

N!=X を満たすような正の整数 N を求めてください。

ただし、N!N の階乗を表し、そのような N がただ一つ存在することは保証されています。

制約

  • 2 \leq X \leq 3 \times 10^{18}
  • N!=X を満たすような正の整数 N がただ一つ存在する
  • 入力は全て整数

入力

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

X

出力

答えを出力せよ。


入力例 1

6

出力例 1

3

3!=3\times2\times1=6 より、3 を出力します。


入力例 2

2432902008176640000

出力例 2

20

20!=2432902008176640000 より、20 を出力します。

Score : 150 points

Problem Statement

You are given an integer X not less than 2.

Find the positive integer N such that N! = X.

Here, N! denotes the factorial of N, and it is guaranteed that there is exactly one such N.

Constraints

  • 2 \leq X \leq 3 \times 10^{18}
  • There is exactly one positive integer N such that N!=X.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

X

Output

Print the answer.


Sample Input 1

6

Sample Output 1

3

From 3!=3\times2\times1=6, print 3.


Sample Input 2

2432902008176640000

Sample Output 2

20

From 20!=2432902008176640000, print 20.

E - ABC conjecture

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 300

問題文

正の整数 N が与えられます。

A\leq B\leq C かつ ABC\leq N であるような正の整数の組 (A,B,C) の個数を求めてください。

なお、制約の条件下で答えは 2^{63} 未満であることが保証されます。

制約

  • 1 \leq N \leq 10^{11}
  • N は整数である

入力

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

N

出力

答えを出力せよ。


入力例 1

4

出力例 1

5

条件を満たす組は (1,1,1),(1,1,2),(1,1,3),(1,1,4),(1,2,2)5 つです。


入力例 2

100

出力例 2

323

入力例 3

100000000000

出力例 3

5745290566750

Score : 300 points

Problem Statement

You are given a positive integer N.

Find the number of triples of positive integers (A, B, C) such that A\leq B\leq C and ABC\leq N.

The Constraints guarantee that the answer is less than 2^{63}.

Constraints

  • 1 \leq N \leq 10^{11}
  • N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the answer.


Sample Input 1

4

Sample Output 1

5

There are five such triples: (1,1,1),(1,1,2),(1,1,3),(1,1,4),(1,2,2).


Sample Input 2

100

Sample Output 2

323

Sample Input 3

100000000000

Sample Output 3

5745290566750