Section 1.4 The Clocks
来源:互联网 发布:奥飞数据 招股说明书 编辑:程序博客网 时间:2024/05/17 07:25
枚举每一种方案就可以过
本人用的是递归处理 思路很容易想 关键是细节处理
做了蛮久的 递归要好好学啊
{
ID: yaoyuan4
PROG: clocks
LANG: PASCAL
}
Program clocks;
type
clock = array['A'..'I'] of longint;
answer = array[1..9] of longint;
const
inf = 'clocks.in'; outf = 'clocks.out';
var
a : clock;
f : answer;
Procedure init;
var
ch : char;
begin
assign(input, inf); reset(input);
for ch := 'A' to 'I' do
begin
read(a[ch]);
a[ch] := (a[ch] div 3) mod 4;
end;
fillchar(f, sizeof(f), 0);
close(input);
end;
Procedure ip(s : string; var x : clock);
var
i : longint;
begin
for i := 1 to length(s) do
x[s[i]] := (x[s[i]] + 1) mod 4;
end;
Procedure worki(var x : clock; y : longint);
begin
case y of
1 : ip('ABDE', x);
2 : ip('ABC', x);
3 : ip('BCEF', x);
4 : ip('ADG', x);
5 : ip('BDEFH', x);
6 : ip('CFI', x);
7 : ip('DEGH', x);
8 : ip('GHI', x);
9 : ip('EFHI', x);
end;
end;
Function ok(x : clock) : boolean;
var
ch : char;
begin
for ch := 'A' to 'I' do
if x[ch] <> 0 then exit(false);
exit(true);
end;
Procedure print(x : answer);
var
i, j, k : longint;
begin
i := 0;
repeat
inc(i);
until x[i] > 0;
assign(output, outf); rewrite(output);
write(i);
dec(x[i]);
for j := i to 9 do
for k := 1 to x[j] do
write(' ', j);
writeln;
close(output);
halt;
end;
Procedure dip(x : clock; y : answer; op : longint);
var
i : longint;
begin
if op > 9 then exit;
for i := 0 to 3 do
begin
if i > 0 then
begin
inc(y[op]);
worki(x, op);
if ok(x) then
print(y);
end;
dip(x, y, op+1);
end;
end;
begin
init;
dip(a, f, 1);
end.
- Section 1.4 The Clocks
- USACO Section 1.4 The Clocks (clocks)
- USCAO section 1.4 The Clocks
- USACO Section 1.4 The Clocks
- USACO section 1.4.2 The Clocks
- USACO Section 1.4.3 The Clocks
- USACO 1.4 The Clocks (clocks)
- USACO 1.4-The Clocks
- 1.4.2---The Clocks
- USACO 1.4 The Clocks
- [USACO 1.4.2] The Clocks
- USACO 1.4.2 The Clocks
- USACO 1.4.2 The Clocks
- The Clocks
- The Clocks
- The Clocks
- The Clocks
- The clocks
- vs 2005 + access 使用 like 问题
- Android JNI 使用的数据结构JNINativeMethod详解
- 内存泄漏
- 远程桌面+花生壳控制adsl动态ip用户的电脑
- swapoff错误Cannot allocate memory
- Section 1.4 The Clocks
- 安装MySQL
- 程序员的优势
- 前言
- 提纲
- 债券溢价的摊销
- 安装 Apache
- 谷歌地球中文版下载
- 谷歌卫星地图