Usaco 1.4.2 时钟(The Clocks)
来源:互联网 发布:淘宝帐号管理在那里 编辑:程序博客网 时间:2024/05/16 09:12
题目:
时钟
来源:
Usaco1.4.2
题目大意:
给定9个时钟,及转动方法,求一个最小的转动方案
移动方法 受影响的时钟
1 ABDE
2 ABC
3 BCEF
4 ADG
5 BDEFH
6 CFI
7 DEGH
8 GHI
9 EFHI
数据范围:
就9个时钟,都有解
样例:
9 9 12
6 6 6
6 3 6
4 5 8 9
做题思路:
每种转动方法使用先后没大碍,所以从小的开始搜,保证最小方案,每一个方法最少用0次, 最多3次,4次等于没用,然后判断皆可。3、6、9、12四个时间可以用1、2、3、0来代替, 看出规律了吧。
知识点:
深搜、模拟
{ID:Dount NamelessTASK:clocksLANG:PASCAL}var a,b:array[1..9] of longint; data:array[1..9,0..5] oflongint=((4,1,2,4,5,0), (3,1,2,3,0,0), (4,2,3,5,6,0), (3,1,4,7,0,0), (5,2,4,5,6,8), (3,3,6,9,0,0), (4,4,5,7,8,0), (3,7,8,9,0,0), (4,5,6,8,9,0)); x,i:longint; ans:string;procedure print;var i,j:longint;begin fori:=1 to 9 do ifa[i] mod 4<>0 then exit;{<如果不是0则说明还有没指向12点的>} ans:=''; fori:=1 to 9 do forj:=1 to b[i] do ans:=ans+chr(i+48)+' ';{<这样在输出前delete一位,省去对方案只有一位数的特殊处理>} delete(ans,length(ans),1); writeln(ans); close(input);close(output); halt;end;procedure dfs(k:longint);{<深搜>}var i,j:longint;begin ifk=10 then print else begin for i:=0 to 3 do{<枚举每个方案的使用情况>} begin b[k]:=i; for j:=1 to data[k,0] do inc(a[data[k,j]],i);{<data[k,0]存的是该方案有哪几个表变了>} dfs(k+1); for j:=1 to data[k,0] do dec(a[data[k,j]],i); end; end;end;begin assign(input,'clocks.in');reset(input); assign(output,'clocks.out');rewrite(output); fori:=1 to 9 do begin read(x); a[i]:=x div 3; end; dfs(1);close(input);close(output);end.题目来源:http://ace.delos.com/usacoprob2?a=YqYGTaSaabV&S=clocks
- Usaco 1.4.2 时钟(The Clocks)
- USACO:1.4.2 The Clocks 时钟(IOI 94) 解析
- 【USACO题库】1.4.2 The Clocks时钟.TJ
- USACO 1.4.2 The Clocks(DFS)
- [USACO 1.4.2] The Clocks
- USACO 1.4.2 The Clocks
- USACO 1.4.2 The Clocks
- USACO 1.4 The Clocks (clocks)
- USACO 1.4-The Clocks
- USACO 1.4 The Clocks
- 【USACO题库】1.4.2 The Clocks(搜索)
- USACO section 1.4.2 The Clocks
- 【USACO题库】1.4.2 The Clocks
- JZOJ1250.【USACO题库】1.4.2 The Clocks
- USACO Section 1.4 The Clocks (clocks)
- USACO Section 1.4 The Clocks
- usaco 1.5.2 The Clocks
- 1250. 【USACO题库】1.4.2 The Clocks (Standard IO)
- 独立博客如何申请谷歌Adsense
- 敏捷测试
- php过滤提交信息防注入
- 栈和堆的区别
- 让你的C程序更有效率的10种方法
- Usaco 1.4.2 时钟(The Clocks)
- jvav中奖取数字游戏
- crontab编译器修改
- TCP/IP建立与断开
- Missing artifact com.sun:tools:jar:1.5.0:system 补充
- ContentProvider的起源和获取
- mongoDB数据库的修复
- SQL-Server2005mssqlserver服务与sqlexpress服务有什么区别
- sprintf的使用