[BZOJ 4173]数学
题目
点这里看题目。
(
分析
看起来这道题的瓶颈是求:
由于显然
方括号为艾弗森括号,类似于“强转布尔型”。
考虑括号内的式子:
设
而不难发现,由于
所以对于满足条件的数,就有
所以
拆成三个求和,都是一个结构:
考虑反向构造:
所以答案就是
代码
#include <cstdio>
typedef long long LL;
#define int LL
const LL mod = 998244353;
template<typename _T>
void read( _T &x )
{
x = 0;char s = getchar();int f = 1;
while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}
while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}
x *= f;
}
template<typename _T>
void write( _T x )
{
if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }
if( 9 < x ){ write( x / 10 ); }
putchar( x % 10 + '0' );
}
LL N, M;
LL phi( LL x )
{
LL ret = x;
for( int i = 2 ; 1ll * i * i <= x ; i ++ )
if( ! ( x % i ) )
{
ret = ret / i * ( i - 1 );
while( ! ( x % i ) ) x /= i;
}
if( x > 1 ) ret = ret / x * ( x - 1 );
return ret;
}
signed main()
{
read( N ), read( M );
LL a = phi( N ) % mod, b = phi( M ) % mod;
write( 1ll * a * b % mod * ( N % mod ) % mod * ( M % mod ) % mod ), putchar( '\n' );
return 0;
}