THE FOOL 【找规律】
题目传送门
题目描述
The Fool is numbered 0 the number of unlimited potential -and therefore does not have a specific place in the sequence of the Tarot cards . The Fool can be placed either at the beginning of the Marjor Arcam or at the end. The Major Arcana is often considered as the Fool's journey through life and as such, he is ever present and therefore needs no number.
Given n∈N+, print the parity of
where
输入
The first line of the input contains one integer T≤100, denoting the number of testcases. Then T testcases follow.
In each of the T testcases, there is a positive number n≤109
输出
For each testcase, print a single line starting with “Case i:”( i indicates the case number) and then "even" or “odd’', separated with a single space.
样例输入
3 1 10000 100000000
样例输出
Case 1: odd Case 2: even Case 3: even
解题思路
列出前五十个数,就会发现一个规律,1-3为奇数,4-8为偶数,9-25为奇数....对n开方下取整然后判断奇偶即可
AC代码
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;int t,n;
int main()
{scanf("%d",&t);for(int k=1;k<=t;k++){scanf("%d",&n);int ans=sqrt(n);if(ans%2==1) printf("Case %d: odd\n",k);else printf("Case %d: even\n",k);}return 0;
}
THE FOOL 【找规律】相关推荐
- 2018.09.01 poj3071Football(概率dp+二进制找规律)
传送门 概率dp简单题. 设f[i][j]表示前i轮j获胜的概率. 如果j,k能够刚好在第i轮相遇,找规律可以发现j,k满足: (j−1)>>(i−1)(j−1)>>(i−1) ...
- 点分治问题 ----------- P3727 曼哈顿计划E[点分治+博弈SG函数打表找规律]
题目链接 解题思路: 1.首先对于每个操作我们实际上是一个博弈问题 对于k=1的操作就是很基础的NIM游戏就是找到一条链的异或和为0 对于k=2的操作通过达打表找规律: 如果s是奇数那么偶数的SG函数 ...
- 数学/找规律/sgu 118 Digital root
题意 定义f(n)为n各位数字之和,如果n是各位数,则n个数根是f(n),否则为f(n)的数根 现在给出n个Ai,求出A1*A2*-*AN + A1*A2*-*AN-1 + - + A1*A2 + A ...
- HDU 5703 Desert 水题 找规律
HDU 5703 Desert 水题 找规律 已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现 ...
- Odd Grasshopper 奇偶找规律
思路 : 首先根据输入的奇偶性分别找规律,发现与输入无关,都满足4个一循环的规律 如果次数n刚好是4的倍数,那么就是x0,否则,找到小于n中最靠近n的一个4的倍数,从它开始模拟到n,就是答案 #inc ...
- 2021 年百度之星·程序设计大赛 - 初赛二 1001 签到(找规律,快速幂)
solution 找规律 #include <iostream> #include <algorithm>using namespace std;const int mod = ...
- 洛谷P2158仪仗队(数学,观察找规律,欧拉函数)
题目链接:https://www.luogu.org/problemnew/show/P2158 读完题被吓到了,这是什么东西. 总之,需要观察+找规律啊!观察可以发现,从第三行开始,第i行中当前直角 ...
- uvalive5092(找规律)
题意: 给出n和m,我们有一个由1~n组成的n个数字的数列a[],如果a[i]>i,我们就把ans++,我们要求出ans==m的数列有多少个. 思路: 打个表,找规律,规律如代码中所示,类似于杨 ...
- uva1511(找规律。。。)
题意: 给出n个点,n个点构成了完全图,每条边是红色或者是蓝色,问这个图中有多少个三角形三条边都是同一个颜色. 思路: 本想暴力,看见榜单上大家都TLE了,不敢暴力了,就找规律. 画图发现,如果三个点 ...
- 汉诺塔问题hdu 2065——找规律
这类题目就是纸上模拟,找规律. 问题描述:在一块铜板上有三根杆,目的是将最左边杆上的盘全部移到右边的杆上,条件是不允许直接从最左(右)边移到最右(左)边(每次移动一定是移到中间杆或从中间移出),也不允 ...
最新文章
- 简述事件接口与事件适配器的联系与区别_设计模式——适配器模式
- RDKit | 通过分析活性化合物确定指标阈值
- 如何从网页上下载Flash?
- ruby学习笔记(2)-chomp,chop的区别
- 我的docker随笔25:一个测试用的镜像制作过程
- iphone以旧换新活动_上苏宁易购预定iPhone12,以旧换新享5G!
- 【整理】超细节的BERT/Transformer知识点
- 广告学毕业论文选题有哪些?
- 智能管家---1.项目搭建
- deep learning 入门
- echarts饼图显示比例
- 如何设置条码标签的打印数量
- 影音视频领域开源项目专区
- vue使用百度地图获取位置信息
- LCS(longest common sequence)算法的实现(十分详细)
- 教你怎么不办会员也可以下载17素材网的源文件
- 全国大学生电子设计竞赛2017年E题 自适应滤波器
- 摘自 寂地《踮脚张望的时光》
- 北邮计算机考研拟录取名单,北京邮电大学发布拟录取名单,390分被刷,多人放弃录取名额!...
- php导购系统,php源码:鱼福CMS淘客导购系统V1.2–免费开源