题解 | #兔子的序列#
兔子的序列
https://www.nowcoder.com/practice/55fc2ebad3fd444bbb1754ba1b259762
#include <stdio.h> #include<math.h> int judge_name(int num, int max, int min, int* map) { for (int i = max; i >= min; i--) { if (map[i] == 1) { double judge = sqrt((double)i); if (judge != (int)judge) { return i; } } } return 0; } int main() { int n = 0; scanf("%d", &n); int num = 0; int map[100000]; int max = 0;//定位最大值 int min = 100000;//定位最小值 for (int i = 0; i < n; i++) { scanf("%d", &num); map[num] = 1; if (num > max) { max = num; } if (num < min) { min = num; } } int ret = judge_name(num, max, min, map); //输出 printf("%d\n", ret); return 0; }