#P17452. 标准卡包 / Card Packs
标准卡包 / Card Packs
Problem Description
You are given two coprime positive integers and . There are different cards, numbered .
In the game, there are two types of standard card packs:
- Type 1 standard packs: there are kinds, labeled (). Pack contains exactly one copy of every card whose number satisfies (so each pack has cards).
- Type 2 standard packs: there are kinds, labeled (). Pack contains exactly one copy of every card whose number satisfies (so each pack has cards).
Now there are cards laid out on the table, and the number of the -th card is . You need to process operations of the following two types:
1 i x: replace the number of the -th card with .2 l r: determine whether the cards in the interval can be partitioned exactly into several standard card packs.
Note: When repacking, every card in the interval must be placed into exactly one pack. Each kind of standard pack may be used any number of times.
Input Format
The first line contains four integers (, , ).
The second line contains integers (), representing the initial number of each card.
The next lines each describe one operation, in the format 1 i x or 2 l r:
- For all operations of the first type, it is guaranteed that and .
- For all operations of the second type, it is guaranteed that .
Output Format
For each 2 l r operation, if the specified cards can be partitioned exactly into several standard card packs, output YES on one line; otherwise output NO on one line.
8 2 3 5
0 0 2 3 4 1 4 2
2 1 5
2 6 8
1 8 5
2 6 8
2 6 7
YES
NO
NO
YES
Hint
When :
- There are two Type 1 standard packs: .
- There are three Type 2 standard packs: .
For the first query, the multiset of cards in the interval is . It can be split into , so the output is YES.
For the last query, the multiset in the interval is . It is exactly one Type 2 standard pack, so the output is YES.
Translated by ChatGPT 5