結果
| 問題 | 
                            No.8110 WIP Editorial
                             | 
                    
| コンテスト | |
| ユーザー | 
                             kokosei
                         | 
                    
| 提出日時 | 2024-04-01 23:26:47 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,166 bytes | 
| コンパイル時間 | 1,534 ms | 
| コンパイル使用メモリ | 127,028 KB | 
| 実行使用メモリ | 29,824 KB | 
| 最終ジャッジ日時 | 2024-09-30 22:48:19 | 
| 合計ジャッジ時間 | 5,705 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | WA * 8 | 
ソースコード
#include <iostream>
#include <atcoder/lazysegtree>
using namespace std;
using ll = long long;
const int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
struct S{
    int val, siz;
};
struct F{
    int add, set;
};
S op(S a, S b){
    return {a.val + b.val, a.siz + b.siz};
}
S e(){
    return {0, 0};
}
S mp(F f, S x){
    if(f.set == -1){
        return {x.val + x.siz * f.add, x.siz};
    }
    return {f.set * x.siz, x.siz};
}
F cm(F f, F g){
    if(f.set == -1){
        return {f.add + g.add, g.set};
    }
    return {0, f.set};
}
F id(){
    return {0, -1};
}
using segtree = atcoder::lazy_segtree<S, op, e, F, mp, cm, id>;
int N, Q;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> N;
    vector<vector<S>> cnt(30, vector<S>(N, {0, 1}));
    for(int i = 0;i < N;i++){
        ll a; cin >> a;
        int id = 0;
        for(int p : primes){
            while(a % p == 0){
                a /= p;
                cnt[id][i].val++;
            }
            id++;
        }
    }
    vector<segtree> seg(30);
    for(int i = 0;i < 25;i++){
        seg[i] = segtree(cnt[i]);
    }
    cin >> Q;
    while(Q--){
        ll t, l, r, x;
        cin >> t >> l >> r >> x;
        l--;
        if(t == 1){
            int id = 0;
            for(int p : primes){
                int num = 0;
                while(x % p == 0){
                    x /= p;
                    num++;
                }
                seg[id].apply(l, r, {0, num});
                id++;
            }
        }else if(t == 2){
            int id = 0;
            for(int p : primes){
                int num = 0;
                while(x % p == 0){
                    x /= p;
                    num++;
                }
                seg[id].apply(l, r, {num, -1});
                id++;
            }
        }else{
            ll ans = 1;
            int id = 0;
            for(int p : primes){
                if(p > x)break;
                ans *= seg[id].prod(l, r).val + 1;
                id++;
            }
            cout << ans << endl;
        }
    }
    return 0;
}
            
            
            
        
            
kokosei