F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

PowMod

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 1971    Accepted Submission(s): 683


Problem Description
Declare:
$k=\sum_{i=1}^{m} \varphi (i*n)\ mod\ 1000000007$

$n$ is a square-free number.

$\varphi $ is the Euler's totient function.

find:
$ans=k^{k^{k^{k^{...^k}}}}\ mod \ p$

There are infinite number of $k$
 

Input
Multiple test cases(test cases $\leq 100$), one line per case.

Each line contains three integers, $n, m$ and $p$.

$1 \leq n, m, p \leq 10^{7}$
 

Output
For each case, output a single line with one integer, ans.
 

Sample Input
1 2 6 1 100 9
 

Sample Output
4 7
 

Author
HIT
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-25 14:35:10, Gzip enabled