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

Count

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 581    Accepted Submission(s): 268


Problem Description
You are given three positive integers $n$, $m$, and $k$.

Your task is to calculate the total number of sequences $A$ of length $n$ that satisfy the following conditions:

1. All elements of $A$ are integers from $1$ to $m$(inclusive).

2. Let $A_i$ be the $i$-th element of sequence $A$. For all positive integers $i$ not exceeding $k$, it is satisfied that $A_i = A_{n-k+i}$.

Calculate the total number of such sequences $A$ that satisfy the conditions and output the result modulo 998244353.
 

Input
The first line contains an integer $T (T\leq 1000)$, representing the number of test cases.

Each of the next $T$ lines contains three integers $n$, $m$, and $k(1 \leq n,m,k \leq 10^{18} , k \leq n)$, representing the parameters for one test case.
 

Output
For each test case, output an integer representing the answer.
 

Sample Input
1 11 2 1
 

Sample Output
1024
 

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-11-22 21:57:19, Gzip enabled