hdu 2053

Ps:找规律题....凡是平方数都是开...WA了一次..数组给的太小?...后来给到3000..就AC了

代码:

#include "stdio.h"
long long dp[3000];
int main(){
 int i,n;
 for(i=1;i<3000;i++)
  dp[i-1]=i*i;
 while(~scanf("%d",&n)){
  for(i=0;i<3000;i++){
   if(n==dp[i]) break;
  }
  if(i>=2999) printf("0\n");
  else printf("1\n");
 } 
 return 0;
}

时间: 2025-01-04 19:40:29

hdu 2053的相关文章

hdu 2053 Switch Game 水题一枚,鉴定完毕

Switch Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10200    Accepted Submission(s): 6175 Problem Description There are many lamps in a line. All of them are off at first. A series of op

HDU 2053 Switch Game(开灯问题,完全平方数)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2053 题目大意:灯开始是关着的,有n盏灯,i从1数到n每当灯的序号是i的倍数的时候就对灯进行一次操作(开->关,关->开),求最后第n盏灯是关着还是开着. 解题思路:直接对第n盏灯模拟也可以,但是有规律更好不是吗~.其实就是判断n的约束奇偶性,奇数就开着,偶数就关着. 当一个数不是完全平方数:如18约数为:(3,6),(2,19),(1,15)约数个数总会是偶数,因为每个约数都有一个对应的不同的约

HDU 2053 Switch Game(开灯问题,唯一分解定理)

Switch Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 15011    Accepted Submission(s): 9160 Problem Description There are many lamps in a line. All of them are off at first. A series of o

HDU 2053 Switch Game

Switch Game 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2053Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Problem Description There are many lamps in a line. All of them are off at first. A series of operations

HDU 2053 Switch Game(数学题)

Switch Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 15008    Accepted Submission(s): 9158 Problem Description There are many lamps in a line. All of them are off at first. A series of o

Hdu2053

Switch Game HDU - 2053 Time limit1000 msMemory limit32768 kB There are many lamps in a line. All of them are off at first. A series of operations are carried out on these lamps. On the i-th operation, the lamps whose numbers are the multiple of i cha

杭电(hdu)2053 Switch Game 水题

Switch Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 13113    Accepted Submission(s): 7970 Problem Description There are many lamps in a line. All of them are off at first. A series of o

HDU分类

模拟题, 枚举 1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201 12

转载:hdu 题目分类 (侵删)

转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093. 1094.1095.1096.1097.1098.1106.1108.1157.116