FATHER AND SON
All submissions for this problem are available.
Like most of the demanding childs.Pratik don't stop until he gets that.He keep on repeating the name of that thing again and again.
For example if he want a computer,He will keep on repeating "computer" again and again.
His dad has decided to answer to his demand as "Yes" or "No" without any delay.Otherwise there would be a lot of repercussions.So, randomly at certain interval,He just answer with "Yes" or "No" by using following rule that he will select
two integers a and b, if the element at the position a is same as element at position b in the repeating chant pratik then he will speak "Yes", Otherwise he will say "No".
Your work is to find the answer of his dad given the name of the demand that pratik is asking for and the random integer his dad has picked.
- First line of the input contains a string S, the name of the item he is demanding.
- Next line contains an integer T, the number of pairs of integer to answer "Yes" or "No".
- For each next N lines, each line contains two space separated integers ai and bi.
- Next T lines each contain 2 integers, a and b.
For each query, print "Yes" or "No" as described above
- 1 ≤ |S| ≤ 10^5
- 1 ≤ Q ≤ 10^5
- 1 ≤ a,b ≤ 10^18
computer 4 3 7 2 10 5 21 11 26
No Yes Yes No
- In the first case the character at 3rd position is 'm' and the character at 7th position is 'e' so the answer is "No"
- In the second case the character at the 2nd position is 'o' and if we repeat the string (like computercomputercomputer...)
the character at 10th position is 'o' so the answer is "Yes"
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.