题解 | #笨小猴#
笨小猴
https://www.nowcoder.com/practice/17865bc2a75c4944a872ef709958c56e
#include <stdio.h> int main() { char arr[100] = {0}; scanf("%s", arr); int i = 0; int max = 0; int mini = 100; while (arr[i] != '\0') { int j = 0; int tempmax = 0; int tempmini = 0; if(arr[i] != ' ') { while (arr[j] != '\0') { if ( arr[j] != ' ' && arr[i] == arr[j] && i != j) { tempmax++; tempmini++; arr[j] = ' '; } j++; } tempmax++; tempmini++; arr[i] = ' '; if (tempmax > max) { max = tempmax; } if (tempmax < mini) { mini = tempmini; } } i++; } if (max - mini < 2) { printf("No Answer\n"); printf("%d",0); } else { int flag = 0; for (int i = 2; i < (max - mini); i++) { if ((max - mini) % i == 0) { flag++; break; } } if (!flag) { printf("Lucky Word\n"); printf("%d",max - mini); } else { printf("No Answer\n"); printf("%d",max - mini); } } return 0; }