scau 18001 Farmer Cat(未)

Description

There are a lot of bulls in SCAU. One of them loves eating fodder. But his owner -- Farmer Cat would not allow him to eat too much fodder, so she plays a game with this bull.

This game is about A SIMPLE MATH PROBLEM : A number between 1 to 2^30 will be given by the Farmer Cat, and the bull has to tell whether the number can be described by the sum of not less than 

two consecutive positive integers or not. If the bull’s answer is right then he can eat the “fodder”, and if not, only “pasture”.

For example, 7 can be described by the sum of 3 and 4. 10 can be described by the sum of 1,2,3 and 4.

For your information, This bull is a genius and he is always able to answer this problem without hesitation. So Farmer Cat asks you for help and write a program to figure out whether 

the answer is right or not. 

 

输入格式

The input consists of T test cases.

The number of test cases (T<=200) is given in the first line of the input file. 

The next T lines , each line consists a number N (1<=N<230) given by the Farmer Cat and an answer(Can or Can't) given by the bull.

 

输出格式

The output should contain T lines, each line consists a word:

If the bull’s answer is right,please print out ”Fodder”.

If it’s wrong.please print out “Pasture”.

 

输入样例

4

7 Can

7 Can't

10 Can

10 Can't

输出样例

Fodder

Pasture

Fodder

Pasture

 ......................................................................................................................................................................................................

这道题自己的思路是x如果可以写成连续和, 1....m....n 那么x=(n+1)*n/2 - (m+1)*m/2 ; 化简后就有x=(n+m+1)*(n-m)/2 ;也就是两个因子相乘。所以枚举1-->x/2求出因子对再判断是否满足上面的那个式子就可以知道了,但是x很大,*2可能会超出整数范围,而且枚举因子也会很慢肯定超时。。

posted @ 2016-03-13 14:40  cherry_yue  阅读(75)  评论(0)    收藏  举报