// Problem: P2260 [清华集训2012]模积和 // Contest: Luogu // URL: https://www.luogu.com.cn/problem/P2260 // Memory Limit: 125 MB // Time Limit: 1000 ms // // Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h> usingnamespace std; #define int long long inlineintread(){int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+ (x<<3)+(ch^48);ch=getchar();}return x*f;} //#define M #define mo 19940417 //#define N int n, m, i, j, k, T; int ans, l, r, P;
intkuai(int a, int b) { int ans=1; while(b) { if(b&1) ans*=a; a*=a; b>>=1; ans%=mo; a%=mo; } return ans; }
voidexgcd(int a, int b, int &x, int &y) { if(b==0) x=1, y=0; else { exgcd(b, a%b, x, y); int z=y; y=x-a/b*y; x=z; } }