Grand Prix of Array Count

시간 제한1초메모리 제한2048 MB

요약
길이 n이고 원소가 1부터 k까지인 배열 중, 합이 짝수인 모든 인덱스 쌍에서 gcd 조건을 만족하는 배열의 개수를 1e9+7로 나눈 나머지로 구한다. n과 k는 1e12까지다.
난이도

어려움10점 중 9점

유형
조합론, 정수론, 수학
정답자
아직 제출이 없습니다

문제

An array aa of length nn is called funny if, for every pair of indices (i,j)(i, j) where 1≤i,j≤n1 \le i, j \le n, the following condition holds: if i+ji+j is an even number, then a_(i+j)/2=gcd(a_i,a_j)a\_{(i+j)/2} = \mathrm{gcd}(a\_i, a\_j). For example, an array \[6,2,2,2,4]\[6,2,2,2,4] is funny.

You are given two positive integers nn and kk. Find the amount of funny arrays of length nn consisting only of integers between 11 and kk. As this number may be very large, output it modulo 109+710^9+7.

입력

The only line contains two integers nn and kk (5≤n≤10125 \le n \le 10^{12}, 2≤k≤10122 \le k \le 10^{12}).

출력

Print a single number: the answer to the problem modulo 109+710^9+7.

힌트

In the first sample, there are 44 funny arrays: \[1,1,1,1,1]\[1,1,1,1,1], \[1,1,1,1,2]\[1,1,1,1,2], \[2,1,1,1,1]\[2,1,1,1,1], \[2,2,2,2,2]\[2,2,2,2,2].

예제2

  1. 예제 1

    입력
    5 2
    
    예상 출력
    4
    
  2. 예제 2

    입력
    32 5
    
    예상 출력
    32