Section 1.2 Palindromic Squares
来源:互联网 发布:朵以正品淘宝折扣店 编辑:程序博客网 时间:2024/04/29 19:23
枚举并判断回文
{
ID: yaoyuan4
PROG: palsquare
LANG: PASCAL
}
Program palsquare;
type
num = array[0..1000] of longint;
const
inf = 'palsquare.in'; outf = 'palsquare.out';
var
n : longint;
a, b : num;
Procedure init;
begin
assign(input, inf); reset(input);
readln(n);
close(input);
assign(output, outf); rewrite(output);
end;
Procedure orz(var c : num; d : longint);
var
i : longint;
begin
fillchar(c, sizeof(c), 0);
repeat
inc(c[0]);
c[c[0]] := d mod n;
d := d div n;
until d = 0;
end;
Procedure ok(c : num; var d : boolean);
var
i : longint;
begin
d := true;
for i := 1 to c[0] div 2 do
if c[i] <> c[c[0]-i+1] then
begin
d := false;
break;
end;
end;
Procedure print(a : num);
var
i : longint;
begin
for i := a[0] downto 1 do
case a[i] of
10 : write('A');
11 : write('B');
12 : write('C');
13 : write('D');
14 : write('E');
15 : write('F');
16 : write('G');
17 : write('H');
18 : write('I');
19 : write('J');
else write(a[i]);
end;
end;
Procedure work;
var
i : longint;
flag : boolean;
begin
for i := 1 to 300 do
begin
orz(b, i*i);
ok(b, flag);
if flag then
begin
orz(a, i);
print(a);
write(' ');
print(b);
writeln;
end;
end;
close(output);
end;
begin
init;
work;
end.
- Section 1.2 Palindromic Squares
- USACO Section 1.2 Palindromic Squares
- USACO Section 1.2 Palindromic Squares
- USACO section 1.2 Palindromic Squares
- [题目] Section 1.2 Palindromic Squares
- USACO Section 1.2 Palindromic Squares
- USACO-Section 1.2 Palindromic Squares[...]
- USCAO Section 1.2 Palindromic Squares
- USACO Section 1.2 Palindromic Squares
- USACA section 1.2.3 Palindromic Squares
- USACO Section 1.2.5 Palindromic Squares
- USACO Section 1.2.4 Palindromic Squares
- USACO-Section 1.2 Palindromic Squares【暴力枚举】
- USACO Training Section 1.2 Palindromic Squares 解题报告&AC代码
- USACO 1.2-Palindromic Squares
- 1.2.4 Palindromic Squares
- usaco 1.2:Palindromic Squares
- USACO 1.2 Palindromic Squares
- Hibernate+Eclipse for j2ee+SQL SERVER的安装及使用问题排除
- ZOJ 1655 Transport Goods (杀入ranklist1000,撒花)
- Linux device driver
- 转型
- poj1274——最大匹配
- Section 1.2 Palindromic Squares
- Asterisk 简介
- 数据库的查询优化方法分析
- SQL基础及安装注意事项
- 8月20日
- SQL 语言基础
- debian squeeze (testing)安装virtualbox
- T-SQL程序设计基础
- 在MFC下如何定义全局变量和全局函数