Section 1.2 Dual Palindromes
来源:互联网 发布:我知女人心南宫寒小说 编辑:程序博客网 时间:2024/05/22 03:19
枚举并判断双回文
本人用了几个过程
shift 进制转换 pal 判断回文
用过程和函数 分步解题 思路就明确了
{
ID: yaoyuan4
PROG: dualpal
LANG: PASCAL
}
Program dualpal;
type
num = array[0..100] of longint;
const
inf = 'dualpal.in'; outf = 'dualpal.out';
var
n, s : longint;
ans : array[0..20] of longint;
Procedure init;
begin
assign(input, inf); reset(input);
readln(n, s);
fillchar(ans, sizeof(ans), 0);
close(input);
end;
Procedure shift(var y : num; o, p : longint);
var
i : longint;
begin
fillchar(y, sizeof(y), 0);
repeat
inc(y[0]);
y[y[0]] := o mod p;
o := o div p;
until o = 0;
end;
Procedure pal(y : num; var p : boolean);
var
i : longint;
begin
p := true;
for i := 1 to y[0] div 2 do
if y[i] <> y[y[0]-i+1] then
begin
p := false;
exit;
end;
end;
Function ok(t : longint) : boolean;
var
i, u : longint;
x : num;
flag : boolean;
begin
u := 0;
for i := 2 to 10 do
begin
shift(x, t, i);
pal(x, flag);
if flag then inc(u);
if u = 2 then exit(true);
end;
exit(false);
end;
Procedure work;
begin
repeat
repeat
inc(s);
until ok(s);
dec(n);
inc(ans[0]);
ans[ans[0]] := s;
until n = 0;
end;
Procedure print;
var
i : longint;
begin
assign(output, outf); rewrite(output);
for i := 1 to ans[0] do
writeln(ans[i]);
close(output);
end;
begin
init;
work;
print;
end.
- Section 1.2 Dual Palindromes
- Section 1.2 Dual Palindromes
- USCAO section 1.2 Dual Palindromes
- USACO Section 1.2 Dual Palindromes
- USACO Section 1.2 Dual Palindromes
- [题目] Section 1.2 Dual Palindromes
- USACO section 1.2 Dual Palindromes
- USCAO Section 1.2 Dual Palindromes
- USACO Section 1.2 Dual Palindromes
- USACO section 1.2.4 Dual Palindromes
- USACO Section 1.2.5 Dual Palindromes
- USACO Training Section 1.2 Dual Palindromes 解题报告&AC代码
- 1.2.5 Dual Palindromes
- USACO 1.2 Dual Palindromes
- 1.2.5 Dual Palindromes
- 1.2 Dual Palindromes
- USACO 1.2 Dual Palindromes
- USCO--1.2Dual Palindromes
- boost1.38 编译
- XML轻松实现XP界面修改
- Linux下时间度量的深入分析
- 跪求帮忙啊
- oracle和unix、linux下载地址
- Section 1.2 Dual Palindromes
- STL的value语义和reference语义【待更新】
- 第三次贴~
- C++数学函数库
- STEP.7.V5.4
- window下cygwin完全卸载办法
- C++数值计算资源
- 初来乍到
- CString , char * ,string 之间的转换