18001 Farmer Cat

时间限制:1000MS  内存限制:65535K
提交次数:0 通过次数:0

题型: 编程题   语言: 不限定

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 230 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
思路:奇数(除1外)都满足条件,偶数中是2的n次方的数(1,2,4,8,16……)都不满足条件,其它偶数满足!
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>int main()
{long long T;scanf("%lld",&T);while(T--){long long n,i,j,flag1,flag2;char judge[10];scanf("%lld",&n);getchar();gets(judge);if(n%2!=0&&n!=1)flag1=1;else{while(n%2==0){n=n/2;}if(n==1)flag1=0;elseflag1=1;}if(strcmp(judge,"Can")==0)flag2=1;if(strcmp(judge,"Can't")==0)flag2=0;if(flag2==flag1)printf("Fodder\n");elseprintf("Pasture\n");}return 0;
}
												

18001 Farmer Cat相关推荐

  1. 矩阵拼接 cat padding_pytorch

    20201219 两个向量形成一个元素 aa=np.array([1,2]) bb=np.array([2,2]) cc=np.vstack((aa,bb)) dd=np.vstack((aa,bb) ...

  2. PyTorch的torch.cat

    字面理解:torch.cat是将两个张量(tensor)拼接在一起,cat是concatnate的意思,即拼接,联系在一起. 例子理解 import torch A=torch.ones(2,3) # ...

  3. 应用监控CAT之cat-client源码阅读(一)

    CAT 由大众点评开发的,基于 Java 的实时应用监控平台,包括实时应用监控,业务监控.对于及时发现线上问题非常有用.(不知道大家有没有在用) 应用自然是最初级的,用完之后,还想了解下其背后的原理, ...

  4. pytorch学习——torch.cat和torch.stack的区别

    合并tensors torch.cat 沿着特定维数连接一系列张量. torch.stack 沿新维度连接一系列张量. torch.cat 在给定维度中连接给定的 seq 个张量序列. 所有张量必须具 ...

  5. linux cat 查看文件内容 不带#号的,Linux下如何不用cat命令读取文件内容

    本文最后更新于2018年1月28日,已超过 1 年没有更新,如果文章内容失效,还请反馈给我,谢谢! =Start= 缘由: 在微信群里看到的一个讨论,觉得挺有启发意义的,所以在此整理一下,方便以后学习 ...

  6. 使用cat,awk和sort命令从nginx访问日志中统计user-agent类型

    业务场景描述如下: 我有一个Nginx的web服务器,需要从统计日志中统计有哪些类型的设备终端和浏览器访问了我的网站. 访问日志中的每条记录是这样的: 使用下面的命令得到user-agent所在的字段 ...

  7. 每天一个linux命令(10):cat 命令

    cat命令的用途是连接文件或标准输入并打印.这个命令常用来显示文件内容,或者将几个文件连接起来显示,或者从标准输入读取内容并显示,它常与重定向符号配合使用. 1.命令格式: cat [选项] [文件] ...

  8. 使用cat /proc/进程id/maps 查看进程内存映射

    proc/<PID>/maps 查看进程的虚拟地址空间是如何使用的. 该文件有6列,分别为: 地址:库在进程里地址范围 权限:虚拟内存的权限,r=读,w=写,x=,s=共享,p=私有: 偏 ...

  9. linux mv 环境变量,linux环境变量,cp,mv命令,more,less,cat,tail,head,的使用...

    linux环境变量,cp,mv命令,more,less,cat,tail,head,的使用 [email protected] ~]# cp /usr/bin/ls   /tmp/ [[email p ...

最新文章

  1. 怎么找思科答案最快_成功闯入思科的面试经历
  2. linux libffi 简介 高级语言互调库
  3. RV1108之MiniGui显示参数配置
  4. Numpy-浅拷贝和深拷贝
  5. LogMiner学习笔记
  6. hibernate jpa_使用Hibernate(JPA)一键式删除
  7. ORA-28056:Writing audit records to Windows EventLog failed的问题
  8. python动态心形代码_Python实现酷炫的动态交互式数据可视化,附代码!
  9. SPSS 非参数检验(图文+数据集)【SPSS 021期】
  10. TBSchedule调度平台疑难解答
  11. 方程求全微分结果和法向量、切向量的关系
  12. VUE项目配置SSR
  13. 苹果手机注册时显示链接服务器出现问题,苹果连接服务器出现问题怎么办_苹果id连接到服务器时出现问题的解决方法...
  14. Code Craft(编程匠艺)之代码的生命(一)
  15. win10电脑wifi显示无法连接服务器,Win10怎么连Wifi?解决Win10无法连接wifi无线网络的方法图文详解...
  16. 数字化转型小贴士和陷阱
  17. [HSCSEC 2023] rev,pwn,crypto,Ancient-MISC部分
  18. npm install或者yarn install时报错fatal: unable to access
  19. linux怎么设置开机启动守护进程,linux设置开机自启-systemctl
  20. Unity定时重复调用方法--Invoke方法

热门文章

  1. 【天光学术】基础教育论文:中小学传统文化教育存在的问题和对策分析(节选)
  2. JavaScript:表格生成器
  3. 设计黄金法则永不改变
  4. 经典 Fuzzer 工具 AFL 模糊测试指南
  5. 路由器备份文件查看 Android,【教程】用安卓系统 手机查看路由U盘内容的方法...
  6. 贪心算法-大整数乘法/加法/减法
  7. 百慕大财政部批准Velocity Ledger ICO申请
  8. 暴走的Polkadot (DOT)(上)
  9. Java期末大作业基础项目--在线学生选课系统
  10. BugKu_python_jail