求114514^n的因子和mod 19260817

11451 4 n 114514^n 114514n 的因子和 m o d 19260817 mod 19260817 mod19260817 19260817 19260817 19260817 是质数, 114514 114514 114514 的质因子是 2 , 31 , 1847 2,31,1847 2311847

2 , 1 2 ,1 21
31 , 1 31 ,1 311
1847 , 1 1847 ,1 18471

114514 114514 114514 的因子和为 s ( 2 ) ∗ s ( 31 ) ∗ s ( 1847 ) = 3 ∗ 32 ∗ 1845 = 177120 ‬ s(2)*s(31)*s(1847)=3*32*1845=177120‬ s(2)s(31)s(1847)=3321845=177120

如果 p p p 是素数

s ( p n ) = 1 + p + p 2 + . . . + p n = ( p ( n + 1 ) − 1 ) / ( p − 1 ) s(p^n)=1+p+p^2+...+p^n= (p^(n+1)-1) /(p-1) s(pn)=1+p+p2+...+pn=(p(n+1)1)/(p1)

s ( 11451 4 n ) = s ( 2 n ) ∗ s ( 3 1 n ) ∗ s ( 184 7 n ) s(114514^n)=s(2^n)*s(31^n)*s(1847^n) s(114514n)=s(2n)s(31n)s(1847n)

a = s ( 2 n ) = 2 ( n + 1 ) − 1 a=s(2^n)=2^(n+1)-1 a=s(2n)=2(n+1)1

b = s ( 3 1 n ) = ( 3 1 ( n + 1 ) − 1 ) / 30 b=s(31^n)=(31^(n+1)-1)/30 b=s(31n)=(31(n+1)1)/30

c = s ( 184 7 n ) = ( 184 7 ( n + 1 ) − 1 ) / 1846 c=s(1847^n)=(1847^(n+1)-1)/1846 c=s(1847n)=(1847(n+1)1)/1846

30 30 30 的逆元 10914463 10914463 10914463

1846 1846 1846 的逆元 1387697 1387697 1387697

a = ( p o w ( 2 , n + 1 , 19260817 ) − 1 ) % 19260817 a=(pow(2,n+1,19260817)-1)\%19260817 a=(pow(2,n+1,19260817)1)%19260817

b = ( p o w ( 31 , n + 1 , 19260817 ) − 1 ) ∗ 10914463 ) % 19260817 b=(pow(31,n+1,19260817)-1)*10914463)\%19260817 b=(pow(31,n+1,19260817)1)10914463)%19260817

c = ( p o w ( 1847 , n + 1 , 19260817 ) − 1 ) ∗ 1387697 ) % 19260817 c=(pow(1847,n+1,19260817)-1)*1387697)\%19260817 c=(pow(1847,n+1,19260817)1)1387697)%19260817

a n s = ( a ∗ b ∗ c ) % 19260817 ; ans=(a*b*c)\%19260817; ans=(abc)%19260817;

AC代码:

ll qpow(ll x, ll n, ll mod)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = x * x % mod, n >>= 1;
	}
	return res;
}

const int mod = 19260817;
int main()
{
	int t;
	int n;
	sd(n);
	ll a = (qpow(2, n + 1, mod) - 1) % mod;
	ll inv1 = qpow(30, mod - 2, mod);
	ll b = (((qpow(31, n + 1, mod) - 1) * inv1) % mod);
	ll inv2 = qpow(1846, mod - 2, mod);
	ll c = (((qpow(1847, n + 1, mod) - 1) * inv2) % mod);
	ll ans = (a * b % mod * c % mod) % mod;
	pld(ans);
	return 0;
}

你可能感兴趣的:(数论)