This commit is contained in:
Zengtudor 2024-11-14 13:50:09 +08:00
parent 45b9ef50e3
commit 02a4aabd9e

View File

@ -1,4 +1,6 @@
#include <algorithm>
#include <cstdint> #include <cstdint>
#include <cstring>
#include <iostream> #include <iostream>
using ll = int64_t; using ll = int64_t;
@ -6,33 +8,55 @@ using ll = int64_t;
auto &ci = std::cin; auto &ci = std::cin;
auto &co = std::cout; auto &co = std::cout;
const ll mn = 1e6+5; const ll mxn = 1e6+5;
ll n; ll *a{new ll[mxn]}, *fcts{new ll[mxn]}, *mnfct{new ll[mxn]};
ll *a = new ll[mn], *sa = new ll[mn]; auto ispm = new bool[mxn];
ll lb(ll n){ ll lb(ll n){
return n&(-n); return n&(-n);
} }
int main(){ int main(){
ll n;
ci>>n; ci>>n;
for(ll i{1};i<=n;i++){ ll mxa{};
for(ll i{0};i<n;i++){
ci>>a[i]; ci>>a[i];
mxa = std::max(mxa, a[i]);
} }
for(ll i{1};i<(1<<(n));i++){ std::fill(ispm, ispm+mxa+1, true);
ll now{i}; ispm[1]=false;
ll san{}; for(ll i{1};i<=mxa;i++)mnfct[i]=i;
for(ll j{0};j<=n;j++){ for(ll i{2};i<=mxa;i++){
if((1<<j)&i){ if(ispm[i]){
sa[++san]=a[j+1]; for(ll j{i+i};j<=mxa;j+=i){
if(ispm[j]){
ispm[j]=false;
mnfct[j]=i;
}
} }
} }
// for(ll i{1};i<=san;i++){
// co<<sa[i]<<' ';
// }
// co<<'\n';
} }
// for(ll i{1};i<=mxa;i++)co<<mnfct[i]<<' ';
// co<<'\n';
for(ll i{1};i<(1<<(n));i++){
// std::fill(fcts, fcts+n, 0);
memset(fcts, 0, sizeof(ll)*mxa);
for(ll j{0};j<n;j++){
if((1<<j)&i){
ll now = a[j];
while(now!=1){
// co<<nv(now)<<'\n';
fcts[mnfct[now]]++;
now/=mnfct[now];
}
}
}
}
// for(ll i{1};i<=mxa;i++)co<<fcts[i]<<' ';
// co<<'\n';
} }