a436: Uncle Benson React to Uncle Benson POOPS
標籤 : DP Uncle Roger
通過比率 : 15人/17人 ( 88% ) [非即時]
評分方式:
Tolerant

最近更新 : 2020-10-15 20:40

內容

Hello, niece and nephew, it's Uncle Benson.

Uncle Benson realized there is this new wonderful form of sequence called "poop".

Just yesterday, Uncle Benson don't know what poop is.

But I discovered this wonderful page called, "poopsequences".

So interesting, Uncle Benson love so much.

So today, Uncle Benson gonna react to niece and nephew poops of Uncle Benson.

Some are good, some are terrible.

 

Now you are Uncle Benson, and you want to react to the poops.

What you need to do is to distinguish between good poop and bad poop.

You will have given a page in each testcase.

Each page contains three coefficients $a,b,c$ and a bunch of poops.

A poopsequence is good if $P_{n+3}=a\times P_{n+2}+b\times P_{n+1}+c\times P_{n}$,  $n\in \mathbb{N}$

A poop contain two integers $Q_i,A_i$ ,and a poop is good if $P_{Q_{i}}\equiv A_i \ (mod \  998244353)\ $

The base cases are $P_1=1, P_2=2, P_3=3$

輸入說明

The first line contains one integer $n$: the number of poops.

The second line contains three integer $a$, $b$, $c$: the coefficients of the poopsequence.

In each of the next of $n$ lines there are the poops.

The $i$-th line contains two integers $Q_i$ and $A_i$

輸出說明

For each poop, print "fuiyoh"(without quotes) if it's good.

Otherwise, print "haiyaa"(without quotes).

範例輸入
3
1 1 1
1 2
2 2
3 2
範例輸出
haiyaa
fuiyoh
haiyaa
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (30%): 1.0s , <1M
公開 測資點#1 (30%): 1.0s , <1M
公開 測資點#2 (40%): 1.0s , <1M
提示 :

$\forall$ $1\leq n\leq 10^5$, $1\leq a,b,c\leq 10^3$, $max(Q_i) \leq 10^5$, $-10^9\leq A_i\leq 10^9$

#0 $1\leq n\leq 10^2$, $max(Q_i) \leq 10^2$

#1 $1\leq n\leq 10^3$, $max(Q_i) \leq 10^3$

#2 $no\ limit$

標籤:
DP Uncle Roger
出處:
109學年度進階班作業 [管理者:
fdhs107_KonChin... (konchin)
]


編號 身分 題目 主題 人氣 發表日期
沒有發現任何「解題報告」