184 条题解
-
0td650739 LV 8 @ 2013-08-07 11:29:38
O(∩_∩)O~ 刷水题最舒服了。。。
Var f:array['a'..'z'] of longint;
s:string;
k:char;
max,min,i:longint;
Function check(x:longint):boolean;
Var i:longint;
Begin
If (x=0) or (x=1) then exit(false);
If x=2 then exit(true);
For i:=2 to trunc(sqrt(x)) do
If x div i=0 then exit(false);
exit(true);
End;
Begin
min:=maxlongint;
max:=0;
Readln(s);
For i:=1 to length(s) do inc(f[s[i]]);
For k:='a' to 'z' do
Begin
If max<f[k] then max:=f[k];
If (min>f[k]) and (f[k]<>0) then min:=f[k];
End;
If check(max-min) then
Begin
writeln('Lucky Word');
Writeln(max-min);
End
Else
Begin
writeln('No Answer');
writeln(0);
End;
readln;
End. -
02013-07-31 14:12:01@
哪位大牛帮我改改
测试数据 #0: TimeLimitExceeded, time = 1014 ms, mem = 732 KiB, score = 0
测试数据 #1: TimeLimitExceeded, time = 1014 ms, mem = 732 KiB, score = 0
测试数据 #2: TimeLimitExceeded, time = 1014 ms, mem = 732 KiB, score = 0
测试数据 #3: TimeLimitExceeded, time = 1014 ms, mem = 732 KiB, score = 0
测试数据 #4: TimeLimitExceeded, time = 1014 ms, mem = 732 KiB, score = 0
测试数据 #5: TimeLimitExceeded, time = 1014 ms, mem = 732 KiB, score = 0
测试数据 #6: TimeLimitExceeded, time = 1014 ms, mem = 728 KiB, score = 0
测试数据 #7: TimeLimitExceeded, time = 1014 ms, mem = 728 KiB, score = 0
测试数据 #8: TimeLimitExceeded, time = 1014 ms, mem = 732 KiB, score = 0
测试数据 #9: TimeLimitExceeded, time = 1014 ms, mem = 728 KiB, score = 0
TimeLimitExceeded, time = 10140 ms, mem = 732 KiB, score = 0
var cha,cha1,maxn,minn,t1,i,j,k:longint;
ch:char;
t:array[1..100] of char;
b:array[1..26] of integer;
begin
k:=1;
while not eof do
begin
while not eoln do
begin
read(ch);
if ch<>' ' then t[k]:=ch else k:=k+1;
end;
k:=k+1;
end;
for i:=1 to k do
begin
case t[i] of
'a':inc(b[1]);
'b':inc(b[2]);
'c':inc(b[3]);
'd':inc(b[4]);
'e':inc(b[5]);
'f':inc(b[6]);
'g':inc(b[7]);
'h':inc(b[8]);
'i':inc(b[9]);
'j':inc(b[10]);
'k':inc(b[11]);
'l':inc(b[12]);
'm':inc(b[13]);
'n':inc(b[14]);
'o':inc(b[15]);
'p':inc(b[16]);
'q':inc(b[17]);
'r':inc(b[18]);
's':inc(b[19]);
't':inc(b[20]);
'u':inc(b[21]);
'v':inc(b[22]);
'w':inc(b[23]);
'x':inc(b[24]);
'y':inc(b[25]);
'z':inc(b[26]);
end;
end;
for i:=1 to 26 do
begin
if b[1]<b[j] then begin
t1:=b[i];
b[i]:=b[j];
b[j]:=t1;
end;
end;
maxn:=b[1];
for i:=1 to 26 do
begin
if b[1]>b[j] then begin
t1:=b[i];
b[i]:=b[j];
b[j]:=t1;
end;
end;
minn:=b[1];
cha:=maxn-minn;
for i:=1 to cha do
if cha mod i=0 then inc(cha1);
if cha<=1 then begin writeln('No Answer'); writeln('0'); halt; end;
if cha1=2 then begin writeln('Lucky Word'); writeln('cha'); halt; end;
writeln('No Answer');
writeln('0');
end. -
02013-07-30 12:16:17@
编译成功
测试数据 #0: Accepted, time = 0 ms, mem = 768 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 772 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 768 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 772 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 768 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 772 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 772 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 772 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 768 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 768 KiB, score = 10
Accepted, time = 0 ms, mem = 772 KiB, score = 100
哈哈,秒杀,有木有。
-
02013-07-06 17:08:00@
水爆了,3行代码,模拟题拿来练Python 的 onliner真好
count = map(lambda w:word.count(w),set(raw_input()))
count.sort()
print {True:"Lucky Word\n%s"%(count[-1]-count[0]), False:"No Answer\n0"}[(count[-1]-count[0]) in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]] -
02013-05-16 14:17:14@
水过~
VijosEx via JudgeDaemon2/13.4.6.0 via libjudge
编译成功foo.cpp: In function 'int main()':
foo.cpp:21:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
测试数据 #0: Accepted, time = 0 ms, mem = 476 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 472 KiB, score = 10
测试数据 #2: Accepted, time = 7 ms, mem = 476 KiB, score = 10
测试数据 #3: Accepted, time = 15 ms, mem = 472 KiB, score = 10
测试数据 #4: Accepted, time = 15 ms, mem = 472 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 472 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 476 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 468 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 472 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 472 KiB, score = 10
Accepted, time = 37 ms, mem = 476 KiB, score = 100#include <string>
#include <algorithm>
#include <iostream>
#include <math.h>using namespace std;
bool check(int x){
if (x<2) return false;
for (int i=2;i<=int(sqrt(x));i++){
if (!(x%i)) return false;
}
return true;
}int main(){
string s;
int p[26];
for (int i=0;i<26;i++) p[i]=0;
cin>>s;
for (int i=0;i<s.size();i++){
p[int(s[i])-int('a')]++;
}
int minx=0x7fffffff,maxx=-0x7fffffff;
for (int i=0;i<26;i++){
if (p[i]){
minx=min(p[i],minx);
maxx=max(p[i],maxx);
}
}
if (check(maxx-minx)){
cout<<"Lucky Word"<<endl<<maxx-minx<<endl;
} else cout<<"No Answer"<<endl<<0<<endl;
// system("pause");
return 0;
} -
02013-05-11 21:27:52@
这种渣题还敢出在提高组
-
02013-03-13 17:33:52@
var a:string;j:char;
i,m,n,q:longint;c:boolean;
b:array['a'..'z'] of longint;begin
c:=true;
readln(a);m:=0;n:=maxlongint;
for i:=1 to length(a) do
b[a[i]]:=b[a[i]]+1;
for j:='a' to 'z' do
begin
if (b[j]<>0) and (b[j]>m) then m:=b[j];
if (b[j]<>0) and (b[j]<n) then n:=b[j];
end;
q:=m-n;
for i:=2 to q-1 do
if q mod i = 0 then c:=false;
if (q=0) or (q=1) then c:=false;
if c=true then
begin
writeln('Lucky Word');
writeln(q);
end
else
begin
writeln('No Answer');
writeln('0');
end;
end. -
02012-10-11 21:08:31@
庆祝第50道AC
思路:读字符串,用一个'a'..'z'的整形数组存放每个字符出现几次,再寻找第一个不为0的字符,把maxn和minn的指针都指向这里。之后用循环判断有没有比maxn更大的和比minn更小的,有就移动指针。
定义函数prime(x)判断素数,if prime(maxn-minn) then....else....
一遍AC -
02012-08-04 15:47:19@
点击查看代码
-
02010-07-17 23:37:16@
呜呜呜……No Answer要打零
-
02010-04-05 19:03:09@
没什么好说的 0和1不是质数 判断时要注意。
其实后来想想直接弄数组也是个保险的方法呵呵
简单的不行了,细心就好 -
02009-11-19 21:11:42@
AC
program v1;
var i,j,len,t,min,max:integer;
a:array[0..100]of char;
s:string;function prime(x:integer):boolean;
begin
if x -
02009-11-08 16:06:14@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms
program ex_001;
var
a:array[1..100] of char;
b:array['a'..'z']of integer;
z,p,q,m:longint;
i:char;
w:string;
r:boolean;
function pd (n:integer):boolean;
begin
if nq then q:=b[i];
for i:= 'a' to 'z' do
if (b[i] -
02009-11-04 21:38:05@
去年考时80。。。
刚才做60。。。
一看,原来素数的集合错了。。。。。
更正后AC~~ -
02009-11-04 08:01:48@
-
02009-11-03 21:41:01@
program sadf;
type
b=set of 0..100;
const o:b=[2,3,11];
var
a:array['a'..'z'] of integer;
c:char;
i,m,n,d:integer;
p:string;
begin
m:=0;
n:=100;
read(p);
fillchar(a,sizeof(a),0);
for i:=1 to length(p) do
a[p[i]]:=a[p[i]] + 1;
for c:='a' to 'z' do
begin
if ma[c]) and (a[c]>0) then
n:=a[c];
end;
d:=m-n;
if d in o then
begin
writeln('Lucky Word');
writeln(d);
end
else
begin
writeln('No Answer');
writeln('0');
end;
end.├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms我蒙的
但是竟然全部蒙对了…… -
02009-11-02 17:27:13@
简单
-
02009-10-31 22:05:50@
#include
#include
using namespace std;
const int N=101;
int coun[30];
int maxn,minn=1000;
int pd(int x)
{
if (x -
02009-10-29 21:55:37@
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms -
02009-10-29 10:31:56@
我垃圾啊我2次才A啊
我去年就写错了我怎么那么垃圾啊。。。