hdoj2053(switch game
来源:互联网 发布:mac地址ip地质作用 编辑:程序博客网 时间:2024/06/06 13:19
#include <stdio.h>#include <math.h>int main(){ int n; while(scanf("%d",&n)!=EOF) { int ans1; double ans2; ans1=sqrt(n); ans2=sqrt(n); if(ans1==ans2) { printf("1\n"); } else printf("0\n"); } return 0;}
已AC;
如果定义一个数组来代表灯,然后两轮循环,因为n<10^5所以后面可能会超时。还是直接判断好
这题就是那个什么拍灯问题。。。每轮拍一次灯,第n次拍n的倍数的灯,刚开始灯全灭,基本就是一样,最后能亮的只有编号为完全平方数的灯,所以只要判断n是否为完全平方数就可以。
为什么是完全平方数才行呢。。。因为很明显一个灯要被按奇数次才能亮,也就是编号的约数包括1和本身有奇数个,而如果不是完全平方数的话肯定就是一对一对的约数吧。。。所以只有编号为完全平方数才有奇数个约数,才会亮到最后
0 0
- HDOJ2053 Switch Game
- hdoj2053 Switch Game
- hdoj2053(switch game
- hdoj2053
- HDOJ2053
- hdoj2053
- Switch Game
- Switch Game
- Switch Game
- Switch game
- HDOJ 2053 Switch Game
- 2053 Switch Game
- Hdu 2053 - Switch Game
- Switch Game + 枚举
- HDU 2053 Switch Game
- hdu 2053 Switch Game
- HDU_2053 Switch Game
- Switch Game 2053
- Xcode快捷键
- hdu--4455+ Substrings+2012杭州区域赛C题+DP
- Swift-- 方法
- [TwistedFate]属性property
- zoj 3891 K-hash(后缀自动机)
- hdoj2053(switch game
- Intent 传数据
- POJ 3009 dfs暴搜
- 外键约束和级联操作
- Java学习笔记(1):重载方法
- 【编程开发】opencv实现对Mat中某一列或某一行的元素进行normalization
- READING NOTE: Two-Stream Convolutional Networks for Action Recognition in Videos
- 用于Android ART虚拟机JNI调用的NativeBridge介绍
- 配置ADT