题目地址:http://codevs.cn/problem/1053/

分析:

模拟

代码:

var s:string;

a:array['a'..'z'] of longint;

i,j,t,n:longint;

k:char;

d:array[1..100000] of longint;

function cf(x:longint):boolean;

var i,y:longint;

begin

y:=0;

for i:=2 to trunc(sqrt(x)) do

if x mod i=0 then y:=1;

if (x=1) or (y=1) then cf:=false

else cf:=true;

end;

begin

readln(s);

for i:=1 to length(s) do

a[s[i]]:=a[s[i]]+1;

for k:='a' to 'z' do

if a[k]>0 then

begin

n:=n+1;

d[n]:=a[k];

end;

for i:=1 to n-1 do

for j:=i+1 to n do

if d[i]<d[j] then begin t:=d[i]; d[i]:=d[j]; d[j]:=t; end;

i:=d[1]-d[n];

if (cf(i)) and (i>=1) then begin writeln('Lucky Word');writeln(i); end

else begin writeln('No Answer'); writeln('0'); end;

end.

codevs1052的更多相关文章

  1. codevs1052 地鼠游戏

    1052 地鼠游戏 题目描述 Description 王钢是一名学习成绩优异的学生,在平时的学习中,他总能利用一切时间认真高效地学习,他不但学习刻苦,而且善于经常总结.完善自己的学习方法,所以他总能在 ...

随机推荐

  1. 数据库ifnull方法

    IFNULL(expr1,expr2)如果expr1不是NULL,IFNULL()返回expr1,否则它返回expr2.IFNULL()返回一个数字或字符串值.例如: ifnull() 如果sum(t ...

  2. Intellij IDEA插件 - Scroll From Source

    Intellij IDEA插件 - Scroll From Source 学习了:http://blog.csdn.net/luonanqin/article/details/41088171 可以自 ...

  3. 暑假NOIP期末考试【1】—— Phantom

    Phantom •题目名称: phantom •时间限制:1 秒 •空间限制:256 MiB 题目描写叙述 在一个无限大的棋盘上.排列着 n * n 枚棋子,形成一个 n 行 n 列的方阵.棋子能够横 ...

  4. LeetCode211:Add and Search Word - Data structure design

    Design a data structure that supports the following two operations: void addWord(word) bool search(w ...

  5. java之 ------ DAO设计模式的【具体解释】及常见设计模式的【应用】

    DAO Data Access Object(数据訪问接口) 一.场景和问题 在Java程序中.常常须要把数据持久化,也须要获取持久化的数据.可是在进行数据持久化的过程中面临诸多问题(如:数据源 不同 ...

  6. 英语影视台词---八、the shawshank redemption

    英语影视台词---八.the shawshank redemption 一.总结 一句话总结:肖申克的救赎 1.It's funny. On the outside, I was an honest ...

  7. 几个常用ORACLE运维监控的SQL语句

    1.消耗CPUSELECT a.CPU_TIME, --CPU时间 百万分之一(微秒)              a.OPTIMIZER_MODE,--优化方式              a.EXEC ...

  8. 7.boostUDP通信

    客户端 #include <iostream> #include<string> #include <boost/asio.hpp> #include <st ...

  9. 解决win8.1下sql配置iis的问题

    在配置iis8.5时,ISAPI和CGI限制中没有ASP.NET v4.0.30319, 所以要注册.net 4.0 注册方法为在“运行”中输入cmd,然后在命令行中输入: C:\WINDOWS\Mi ...

  10. [转帖]关于Xilinx下Micro_Blaze中UartLite232外设的使用

    来源:https://blog.csdn.net/shen_you/article/details/78713746