上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 16 下一页
摘要: 1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<queue> 6 7 using namespace std; 8 9 int dx[4] = {1,-1, 0, 0};10 int dy[4] = {0, 0, 1,-1};11 int visit[9][9];12 int map[9][9] = {{1,1,1,1,1,1,1,1,1},{1,0,0,1,0,0,1,0,1},{1,0,0,1,1, 阅读全文
posted @ 2012-03-04 22:28 zhongya 阅读(163) 评论(0) 推荐(1) 编辑
摘要: 1 我的做法是先用BFS求的到达T最短的步数,再用DFS 2 做判断这样的路总共有几条和踩到地雷的路有几条, 3 DFS中用到了剪支,最后求比值即可 4 #include<cstdio> 5 #include<cstdlib> 6 #include<iostream> 7 #include<cstring> 8 #include<queue> 9 10 using namespace std; 11 12 int dx[4] = {1,-1,0, 0}; 13 int dy[4] = {0, 0,1,-1}; 14 char map[ 阅读全文
posted @ 2012-03-03 16:44 zhongya 阅读(176) 评论(0) 推荐(1) 编辑
摘要: 1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 #include<iostream> 5 #include<queue> 6 7 using namespace std; 8 9 int dx[4] = {1, 0, -1, 0};//控制四个方向10 int dy[4] = {0, 1, 0, -1};11 int visit[65536];12 char s[4][4];13 14 typedef struct15 {16 int data;17 int s 阅读全文
posted @ 2012-03-02 23:09 zhongya 阅读(180) 评论(0) 推荐(1) 编辑
摘要: 1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<queue> 5 #include<cmath> 6 #include<cstring> 7 8 using namespace std; 9 10 int dx[] = {1,-1, 0, 0, 0, 0};//三维坐标,六个方向,每次只是其中一个坐标变 化,而保持另外两个不变。11 int dy[] = {0, 0, 1,-1, 0, 0};12 int dz[] = {0, 0 阅读全文
posted @ 2012-03-02 20:49 zhongya 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 1 思路:此题属于隐式图的搜索,从1111出发发散成一个 2 树状结构从每一层中搜索看是否由于目标相等的数,有责打 3 印无责要还原;先对每个数加1,再减1,最后左右互换; 4 #include<cstdio> 5 #include<cstring> 6 #include<iostream> 7 #include<cstdlib> 8 #include<queue> 9 10 using namespace std;11 12 typedef struct13 {14 int data;15 int step;16 }State;// 阅读全文
posted @ 2012-02-26 11:49 zhongya 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 1 仔细分析题目可得到当反射次数为奇数时光想从上面射出, 2 当反射次数为偶数时光线从下面射出。所以分奇数和偶数 3 两种情况考虑。 4 奇数:每个面的光线数目等于本平面上个反射点的光线数目; 5 偶数:每个面的光线树木等于本平面下面的那个反射点的数目; 6 所以有递推关系式可以得到L[i][j] += L[i-1][k];表示i个光线 7 反射的线路数目。 8 #include<stdio.h> 9 #include<string.h>10 11 long long L[60][4], sum;12 int main()13 {14 int i, j, k, n; 1 阅读全文
posted @ 2012-02-25 16:30 zhongya 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<string.h> 3 4 int main() 5 { 6 int i, len; 7 long long num[5]; 8 char str[10002]; 9 while(scanf("%s",str) != EOF)10 {11 len = strlen(str);12 for(i=0; i<5; i++)13 num[i] = 0; 14 for(i=0; i<len; i++)15 {16 switc... 阅读全文
posted @ 2012-02-23 22:21 zhongya 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<string.h> 3 #define maxn 40005//10000阶乘后的位数大约为40000一开始开得太大结果超时了,最后数组开销了之后便AC 4 5 int main() 6 { 7 int i, j, c, s, n, f[maxn]; 8 9 while(scanf("%d",&n)!= EOF)10 { 11 memset(f,0,sizeof(f));12 f[0] = 1; 13 for(i=2; i<=n; i++)14 ... 阅读全文
posted @ 2011-12-22 16:22 zhongya 阅读(141) 评论(0) 推荐(1) 编辑
摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 5 int main() 6 { 7 int i, T, length_a, length_b, j, k; 8 char a[1000], b[1000],c[1000]; 9 scanf("%d", &T);10 for (i=0; i<T; i++)11 {12 scanf("%s%s",a,b);13 length_a = strlen(a);14 length_b = 阅读全文
posted @ 2011-12-18 23:25 zhongya 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 5 int main() 6 { 7 int i, T, length_a, length_b, j, k; 8 char a[1000], b[1000],c[1000]; 9 scanf("%d", &T);10 for (i=0; i<T; i++)11 {12 scanf("%s%s",a,b);13 length_a = strlen(a);14 length_b = 阅读全文
posted @ 2011-12-18 23:22 zhongya 阅读(136) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 16 下一页