結果
| 問題 |
No.8110 WIP Editorial
|
| コンテスト | |
| ユーザー |
kokosei
|
| 提出日時 | 2024-04-01 23:31:33 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,254 bytes |
| コンパイル時間 | 2,041 ms |
| コンパイル使用メモリ | 131,176 KB |
| 実行使用メモリ | 36,096 KB |
| 最終ジャッジ日時 | 2024-09-30 22:49:42 |
| 合計ジャッジ時間 | 9,359 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 8 |
ソースコード
#include <iostream>
#include <atcoder/modint>
#include <atcoder/lazysegtree>
using namespace std;
using ll = long long;
using mint = atcoder::modint998244353;
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{
mint val; int siz;
};
struct F{
mint add; ll 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 {(mint)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{
mint ans = 1;
int id = 0;
for(int p : primes){
if(p > x)break;
ans *= seg[id].prod(l, r).val + 1;
id++;
}
cout << ans.val() << endl;
}
}
return 0;
}
kokosei