URAL_1789_Searching for the Dodecahedron_机智
2015-04-20 06:08
399 查看
Fuck the world!
题意:
一行n个盒子,里面装着一个什么鬼,你不知道它装在哪,每次可以伸手探查一个盒子,如果什么鬼在那个盒子里,就结束,如果不在,什么鬼会往他左边或者右边移动一个盒子,要求对应一个n输出一种策略,一定能找到什么鬼。
策略见代码,实现上注意2要特判。原因如下:在从2向右走的时候可以验证,会找到所有什么鬼初始在偶数位置的情况,然后在n-1再等一次,往回走到2,就会遍历所有什么鬼在奇数位置的情况。
Input
The only input line contains the number n of pedestals in the fourth hall of the Temple of Five Polyhedra (2 ≤
n ≤ 100).
Output
In the first line output the number m (
m ≤ 1000) of touches necessary to find the Dodecahedron. In the second line output
m integers separated with a space; these should be the numbers of pedestals in the order in which the dodecahedra mounted on them should be touched.
The algorithm must achieve the goal for any initial position of the artifact and for any of its admissible transitions. It is guaranteed that there exists at least one such algorithm in which at most one thousand touches are
made.
代码如下:
题意:
一行n个盒子,里面装着一个什么鬼,你不知道它装在哪,每次可以伸手探查一个盒子,如果什么鬼在那个盒子里,就结束,如果不在,什么鬼会往他左边或者右边移动一个盒子,要求对应一个n输出一种策略,一定能找到什么鬼。
策略见代码,实现上注意2要特判。原因如下:在从2向右走的时候可以验证,会找到所有什么鬼初始在偶数位置的情况,然后在n-1再等一次,往回走到2,就会遍历所有什么鬼在奇数位置的情况。
Input
The only input line contains the number n of pedestals in the fourth hall of the Temple of Five Polyhedra (2 ≤
n ≤ 100).
Output
In the first line output the number m (
m ≤ 1000) of touches necessary to find the Dodecahedron. In the second line output
m integers separated with a space; these should be the numbers of pedestals in the order in which the dodecahedra mounted on them should be touched.
The algorithm must achieve the goal for any initial position of the artifact and for any of its admissible transitions. It is guaranteed that there exists at least one such algorithm in which at most one thousand touches are
made.
代码如下:
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int n; int main(){ while(scanf("%d",&n)!=EOF){ if(n==2){ printf("2\n2 2\n"); continue; } printf("%d\n",2*(n-2)); printf("2"); for(int i=3;i<n;++i) printf(" %d",i); for(int i=n-1;i>1;--i) printf(" %d",i); puts(""); } return 0; }
相关文章推荐
- 一道有意思的acm: 1789. Searching for the Dodecahedron
- Ural1540 Battle for the Ring
- URAL 1997 Those are not the droids you're looking for(二分图)
- debian安装vmware tools错误:Searching for a valid kernel header path... The path "" is not valid
- URAL1997-Those are not the droids you're looking for
- Ural 1997-Those are not the droids you're looking for 二分图匹配
- Searching for a valid kernel header path... The path "" is not a valid path to the ***** kernel headers. Would you like to change it? [yes]
- 在 Linux 虚拟机中手动安装或升级 VMware Tools以及Searching for a valid kernel header path... The path "" is not val
- Ural 1540. Battle for the Ring
- The first paper reading——Guttman, R-TREES A DYNAMIC INDEX STRUCTURE FOR SPATIAL SEARCHING
- vmware7安装vmwareTools出现Searching for a valid kernel header path... The path "" is not valid.
- Searching for Outlook Compressible Encryption (PST Data) in the Unallocated Clusters
- Compound class names are not supported. Consider searching for one class name and filtering the results
- Mourning for the people lost in the Second World War
- Sichuan University Programming Contest 2011 Preliminary(for Non-SCUers) / B The Weight of Tree
- there is no source code available for the current location 解决方案
- DM_SESSION_E_AUTH_FAIL for the Centera Accessing
- 【iOS】Signing for requires a development team. Select a development team in the project editor. Code
- no python interpreter configured for the project
- How to create a custom directory for app files inside the ~/Library/Application Support directory.