- 回文数
- 2009-10-14 22:09:21 @
编译通过...
├ 测试数据 01:答案错误...程序输出比正确答案长
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案错误...程序输出比正确答案长
├ 测试数据 04:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Unaccepted 有效得分:50 有效耗时:0ms
const
v:array['A'..'F'] of integer=(10,11,12,13,14,15);
var
n:longint;
a:array[0..100] of longint;
i,k,ans:longint;
s:string;
function pan:boolean;
var x,y:longint;
begin
x:=1;y:=k;
while (a[x]=a[y]) and (x0 then inc(k);
end;
begin
readln(n);
readln(s);
k:=length(s);
for i:=1 to k do
if s[i] in ['0'..'9'] then a[i]:=ord(s[i])-ord('0')
else a[i]:=v[s[i]];
ans:=0;
while (not pan) and (ans30 then writeln('Impossible!')
else writeln('STEP=',ans);
end.
请帮忙看一下啊!!
1 条评论
-
刘锦钰是超圣 LV 7 @ 2016-08-21 17:17:17
#include <iostream>
using namespce std;
int a[101];
bool check(int x) {
int len,b = x,c = x;
for (len=0;b;len++) b /= 10;
if(len%2!=0) return false;
if (x%2!=0) return false;
memset(a,0,sizeof(a));
for(int i = 1;i <= len;i++) {
a[i] = x%10;
x /= 10;
}
for (int i = 1;i <= (len+1)/2;i++)
if (a[i] != a[len+1-i]) return false;
for (int i = 2;i <= sqrt(c);i++)
if(c%i==0) return false;
return true;
}
int main() {
long long L,R;
cin>>l>>r;
for (int i = L;i <= R;i++)
if (check(i)) cout<<i<<endl;
return 0;
}
- 1