CF1182E.Product Oriented Recurrence

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Let fx=c2x6fx1fx2fx3f_{x} = c^{2x-6} \cdot f_{x-1} \cdot f_{x-2} \cdot f_{x-3} for x4x \ge 4 .

You have given integers nn , f1f_{1} , f2f_{2} , f3f_{3} , and cc . Find fnmod(109+7)f_{n} \bmod (10^{9}+7) .

输入格式

The only line contains five integers nn , f1f_{1} , f2f_{2} , f3f_{3} , and cc ( 4n10184 \le n \le 10^{18} , 1f11 \le f_{1} , f2f_{2} , f3f_{3} , c109c \le 10^{9} ).

输出格式

Print fnmod(109+7)f_{n} \bmod (10^{9} + 7) .

输入输出样例

  • 输入#1

    5 1 2 5 3
    

    输出#1

    72900
    
  • 输入#2

    17 97 41 37 11
    

    输出#2

    317451037
    

说明/提示

In the first example, f4=90f_{4} = 90 , f5=72900f_{5} = 72900 .

In the second example, f172.28×1029587f_{17} \approx 2.28 \times 10^{29587} .

首页