摘要:
#include #include using namespace std;
int main()
{ int f[8][8] ={{0, 3, 2, 3, 2, 3, 4, 5}, //因为是8*8的方阵,不是很多数,所以枚举了所有的情况,就是从点(0, 0)到(x, y)最少要几步 {3, 2, 1, 2, 3, 4, 3, 4}, {2, 1, 4, 3, 2, 3, 4, 5}, {3, 2, 3, 2, 3, 4, 3, 4}, ... 阅读全文
摘要:
先分层,然后进行深度优先遍历。#include #include using namespace std; const int maxn = 30 + 10; //每组数据最多有30个数
int n, ok, C[maxn], a[maxn]; //n为每组数据的个数,ok标记是否有等式存在,C用来存路径,a为输入的数组 bool search(int *a, int x, int y, int v) //二分搜索,返回搜索成功与否
{ int m; while(x v) y = m; else x = ... 阅读全文
摘要:
题目简单,但是要注意格式,本人提交5次,前4次均PE#include using namespace std; const int maxn = 10 + 10;
int n, m, cnt; typedef struct datatype //定义数据类型
{ int val; int num;
}data; data a[maxn]; //要输入的数组 void dfs(int cur_sum, int last) //深度优先遍历
{ int i; if(cur_sum == n) //当目前... 阅读全文
摘要:
小心格式,又试了一次PE!!!#include #include using namespace std; const int maxn = 1000 + 10; int a[maxn], b[maxn], d[maxn], G[maxn][maxn]; //a为外显子的起始点,b为外显子的终止点,d为路径长度,G为图 int n, first; //n为外显子的个数,first在输出时做标记(按格式输出的方法之一) int dp(int i) //核心代码,图记忆化搜索
{ int& ans = d[i]; ... 阅读全文