#P11760. [IAMOI R1] 智力检测
[IAMOI R1] 智力检测
Description
The father-in-law gives an array indexed from , where initially .
The mother-in-law asks Xiao L to perform the following operations several times:
In the -th operation, choose two numbers , then execute sequentially:
The first operation has no special restrictions, but for each subsequent operation, it must satisfy .
Given queries, each with two numbers and , determine whether it's possible to make through a finite number of operations.
The queries are independent (i.e., the array should be reset after each query).
Input Format
Due to large input size, it's recommended to use fast input methods.
The input consists of lines:
- The first line contains a positive integer , the number of queries.
- The next lines each contain two positive integers and , representing a query.
Output Format
Output a binary string of length .
The -th character of the string indicates the answer to the -th query:
1if it's possible to make ;0otherwise.
4
6 36
6 35
5 30
5 31
0101
Hint
For of the data:
| Test Case | Special Property | Score | ||
|---|---|---|---|---|
| 1 | None | 20 | ||
| 2 | A | |||
| 3 | None | 30 | ||
| 4 |
Special Property A: Guarantees .
Please optimize your code for constant factors.
The time and memory limits are at least 2.5 times those of the standard solution (with fast I/O).
Due to large input/output volume, we strongly recommend using fast I/O templates.
char *p1,*p2,buf[1<<20];
inline char gc(){if(p1==p2)p2=(p1=buf)+fread(buf,1,1<<20,stdin);return p1==p2?' ':*p1++;}
inline long long read(){
register long long s=0; register char c=gc();
while(c<'0'||c>'9') c=gc();
while(c>='0'&&c<='9') s=(s<<3)+(s<<1)+(c^48),c=gc();
return s;
}
x = read() //input x
Translation by DeepSeek R1
京公网安备 11011102002149号