Các nghiên cứu toán học :https://oeis.org/A057723
Đề bài
Và đây là code của em bị sai ?!
#include <bits/stdc++.h>
#define fi(i, a, b) for(int i=a; i<=b; i++)
#define fid(i, a, b) for(int i=a; i>=b; i--)
#define ll long long
#define mod 1000000007
#define maxn 100005
using namespace std;
ll binpow(ll u, int v){
if (v == 1) return u;
int x = binpow(u, v/2);
if (v%2 == 1) return (u * (x*x%mod)) % mod;
return (x*x) % mod;
}
ll a[maxn];
int main(){
int t;
cin >> t;
while (t--){
ll n, res = 1;
cin >> n;
fi(i, 1, n){
cin >> a[i];
res = (res * a[i]) % mod;
}
fi(i, 1, n){
int x;
cin >> x;
res = (res * (binpow(a[i], x) - 1) / (a[i]-1)) % mod;
}
cout << res << '\n';
}
}
Vì mod là nguyên tố khá to nên chắc chắn gcd(a_i-1, mod)
nên a_i^x-1 chia hết cho a_i-1 thì (a_i^x-1) (\bmod 10^9+7) vẫn chia hết cho a_i-1
Và các số là ước của N' = A_1 ^ {B_1-1} * A_2^{B_2-1} *....A_M^{B_M-1} rồi nhân với A_1 A_2....A_M là tất cả các số thỏa mãn đề rồi