思路
先考虑.
也就是.考虑..因为互质,所以.所以当且仅当且时满足条件.考虑把质因数分解,每个质因数分给和,或者和,或者全部给.形式化地,,.
改成也就是.复杂度.(反正复杂度都这样了还写线性筛干嘛qwq).
代码
#include<bits/stdc++.h> using namespace std; #define i64 long long #define fp( i, b, e ) for ( int i(b), I(e); i <= I; ++i ) #define fd( i, b, e ) for ( int i(b), I(e); i >= I; --i ) #define go( i, b ) for ( int i(b), v(to[i]); i; v = to[i = nxt[i]] ) template<typename T> inline void cmax( T &x, T y ){ x < y ? x = y : x; } template<typename T> inline void cmin( T &x, T y ){ y < x ? x = y : x; } //#define getchar() ( p1 == p2 && ( p1 = bf, p2 = bf + fread( bf, 1, 1 << 21, stdin ), p1 == p2 ) ? EOF : *p1++ ) char bf[1 << 21], *p1(bf), *p2(bf); template<typename T> inline void read( T &x ){ char t(getchar()), flg(0); x = 0; for ( ; !isdigit(t); t = getchar() ) flg = t == '-'; for ( ; isdigit(t); t = getchar() ) x = x * 10 + ( t & 15 ); flg ? x = -x : x; } clock_t t_bg, t_ed; int N, ans(1); bool vis[1000005]; const int mod = 1e9 + 7; signed main(){ t_bg = clock(); read(N); fp( i, 2, N ) if ( !vis[i] ){ for ( int j = i + i; j <= N; j += i ) vis[j] = 1; int c(0); for ( i64 j = i; j <= N; j *= i ) c += N / j; ans = 1ll * ans * ( c << 1 | 1 ) % mod; } printf( "%d\n", ans ); t_ed = clock(); fprintf( stderr, "\n========info========\ntime : %.3f\n====================\n", (double)( t_ed - t_bg ) / CLOCKS_PER_SEC ); return 0; }