题目地址: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. linux环境下删除包含特殊字符的文件或目录

    linux环境下删除包含特殊字符的文件或目录 ls -liUse find command as follows to delete the file if the file has inode nu ...

  2. ASP.NET-JSON.NET技巧

    第一个技巧,字符串转JSON 单条的json数据可以使用JObject.Parse将对象转化成JObject对象,你可以接着使用JsonConvert.SerializeObject方法把这个对象序列 ...

  3. Tomcat远程代码执行漏洞(CVE-2017-12615)修复

    一.漏洞介绍 2017年9月19日,Apache Tomcat官方确认并修复了两个高危漏洞,其中就有Tomcat远程代码执行漏洞,当存在漏洞的Tomcat运行在Windwos主机上,且启用了HTTP ...

  4. UE4在VS2013中各个编译配置代表意义

    UE4中有个各式各样的编译配置,都怎么个意思呢? 对原文的理解和翻译. https://docs.unrealengine.com/latest/INT/Programming/Development ...

  5. Activity嵌套多个Fragment实现横竖屏切换

    一.上图 二.需求 最近项目遇到个横竖屏切换的问题.较为复杂.在此记之. 1.Activity中竖屏嵌套3个Fragment,本文简称竖屏FP1,FP2,FP3. 2.当中竖屏FP1与FP2能够切换为 ...

  6. [LeetCOde][Java] Best Time to Buy and Sell Stock III

    题目: Say you have an array for which the ith element is the price of a given stock on day i. Design a ...

  7. Spring mvc <mvc:resources ***/> 作用

    <!-- 配置静态资源,直接映射到对应的文件夹,不被DispatcherServlet处理,3.04新增功能,需要重新设置spring-mvc-3.0.xsd --> 如在页面需要导入其它 ...

  8. LeetCode 1. Two Sum (c++ stl map)

    题目:https://leetcode.com/problems/two-sum/description/ stl map代码: class Solution { public: vector< ...

  9. nginx禁止特定UA访问

    一.UA是什么? User Agent 简称UA,就是用户代理.通常我们用浏览器访问网站,在网站的日志中,我们的浏览器就是一种UA. 二.禁止特定UA访问 最近有个网站(www.C.com)抄袭公司主 ...

  10. Springboot设置跨域的三种方式

    方式一(精细配置) 在需要跨域的整个Controller或者单个方法上添加@CrossOrigin注解 方式二(全局配置) @Configuration public class WebMvcConf ...