笨小熊
来源:互联网 发布:点胶机编程 编辑:程序博客网 时间:2024/04/26 03:33
用getchar()一个个从输入流取字符居然超时。
#include <cstdio>#include <cstring>#include <cmath>using namespace std;bool isPrime(int n){if(n<2)return false;for(int i = 2; i < (int)sqrt((double)n)+1; i++)if(n%i==0)return false;return true;}int main(){int n;scanf("%d",&n);while(n--){getchar();int A[26];char ch[100+10];memset(A, 0, 26*sizeof(int));scanf("%s",&ch);for(int i = 0; i < strlen(ch); i++){A[ch[i]-'a']++;}int max = 0, min = 1000;for(int i = 0; i < 26; i++){if(A[i]>max)max=A[i];if(A[i]<min&&A[i])min=A[i];}if(isPrime(max-min)){printf("Lucky Word\n%d\n",max-min);}else{printf("No Answer\n0\n");}}return 0;}
0 0
- 笨小熊
- 笨小熊
- 笨小熊
- 笨小熊
- 笨小熊
- 笨小熊
- 笨小熊
- 笨小熊
- 笨小熊
- 笨小熊
- 笨小熊
- 笨小熊
- 笨小熊
- 笨小熊
- 笨小熊
- 笨小熊
- 笨小熊
- 笨小熊
- t
- BIT_COUNT()&BIT_OR()
- hdu 2819
- 解决"taglib definition not consistent with specification version"问题
- Fatal signal 11 (SIGSEGV) 错误
- 笨小熊
- 调制我的Eclipse
- ZigZag Conversion @leet code java
- mysql Got error 28 from storage engine错误,Mysql导致tmp目录空间耗尽问题
- 第10周项目1-程序填充与阅读2及其单步执行
- 指针
- Linux内核中的IPSEC实现(5)
- 【JavaSE】关于switch case的陷阱
- spring拦截器使用及拦截器中获取Controller实例