Hopscotch
来源:互联网 发布:程序员累吗 编辑:程序博客网 时间:2024/05/22 08:09
Hopscotch
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other)
Total Submission(s) : 14 Accepted Submission(s) : 11
Problem Description
The cows play the child's game of hopscotch in a non-traditional way. Instead of a linear set of numbered boxes into which to hop, the cows create a 5x5 rectilinear grid of digits parallel to the x and y axes.
They then adroitly hop onto any digit in the grid and hop forward, backward, right, or left (never diagonally) to another digit in the grid. They hop again (same rules) to a digit (potentially a digit already visited).
With a total of five intra-grid hops, their hops create a six-digit integer (which might have leading zeroes like 000201).
Determine the count of the number of distinct integers that can be created in this manner.
They then adroitly hop onto any digit in the grid and hop forward, backward, right, or left (never diagonally) to another digit in the grid. They hop again (same rules) to a digit (potentially a digit already visited).
With a total of five intra-grid hops, their hops create a six-digit integer (which might have leading zeroes like 000201).
Determine the count of the number of distinct integers that can be created in this manner.
Input
* Lines 1..5: The grid, five integers per line
Output
* Line 1: The number of distinct integers that can be constructed
Sample Input
1 1 1 1 11 1 1 1 11 1 1 1 11 1 1 2 11 1 1 1 1
Sample Output
15题意:能组成多少个不用的数#include <stdio.h>#include <stdlib.h>int map[6][6];int dir[4][2]= {-1,0,1,0,0,-1,0,1};int total=0;int a[6];int b[1000000];void creat(){ int i,j; for(i=0; i<5; i++) for(j=0; j<5; j++) scanf("%d",&map[i][j]);}void sql(int row,int col,int n){ int i,erow,ecol; if(n==6) { int i; int sum=0; for(i=0; i<6; i++) { sum*=10; sum+=a[i]; } if(!b[sum]) { total++; b[sum]=1; } return ; } a[n]=map[row][col]; for(i=0; i<4; i++) { erow=row+dir[i][0]; ecol=col+dir[i][1]; if(erow>=0&&erow<5&&ecol>=0&&ecol<5) { sql(erow,ecol,n+1); } }}int main(){ //memset(b,0,sizeof(b)); creat(); int i,j; for(i=0; i<5; i++) for(j=0; j<5; j++) sql(i,j,0); printf("%d",total); return 0;}
0 0
- Hopscotch
- Hopscotch
- Hopscotch
- * Hopscotch
- Hopscotch
- Hopscotch
- Hopscotch
- POJ3050 Hopscotch
- POJ3258River Hopscotch
- POJ3050--Hopscotch
- River Hopscotch
- POJ3050-Hopscotch
- River Hopscotch
- Hopscotch POJ3050
- River Hopscotch
- River Hopscotch
- poj3258River Hopscotch
- POJ3050 Hopscotch
- java 递归遍历树形结构
- VS2010不能创建项目的解决办法
- Android实现自定义view---绘制图片
- 守护线程与非守护线程
- 演示不同隔离级别下的并发问题
- Hopscotch
- Android Dialog点击按钮不关闭,控制窗口的显示和关闭
- Objective-c中的协议
- 黑马程序员-Oracle(第七讲)
- tomcat配置数据源连接(针对单个web应用)
- 内存溢出相关
- inline函数(摘自C++ Primer的第三版)
- 大数据时代带来的技术变革思考(一)大数据的定义
- 南阳139 我是第几个(康托排序)和南阳143 第几是谁(康托逆排序)