摘要:
http://poj.org/problem?id=3273题意:将n个数分成连续的m组,使得这些组里的数的最大的和最小,输出这个组的和。思路:根据上下界二分逼近。。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int main() 7 { 8 int cost[100010]; 9 int n,m,high = 0,low = 0;10 scanf("%d %d",&n,&m);11 for (int i = 0; i mid)26 {27 ... 阅读全文
posted @ 2013-10-12 22:11
N_ll
阅读(226)
评论(0)
推荐(0)
摘要:
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1269连着做了三个基本的dfs,终于弄懂了搜索和回溯的过程。此题要求输出所有路径,首先给每一个点编号0~n+m;则存储时只需存储编号,由编号得到坐标的方式: x = num/m, y = num%m; 由坐标得到编号的方式:num = x*m+y;注意:本题坐标从(1,1)开始,编号后的坐标从(0,0)开始。 1 #include 2 #include 3 const int Max = 20; 4 int map[Max][Max],vis[ 阅读全文
posted @ 2013-10-12 16:58
N_ll
阅读(231)
评论(0)
推荐(0)
摘要:
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1590 1 #include 2 #include 3 int n,m,s_x,s_y,e_x,e_y; 4 char map[15][15]; 5 6 int Deal(char c) 7 { 8 if(c=='R'&&map[s_x][s_y+1]!='#') 9 {10 s_y++;11 if (s_x==e_x&&s_y==e_y)12 return 1;13 ... 阅读全文
posted @ 2013-10-12 16:42
N_ll
阅读(350)
评论(0)
推荐(0)
摘要:
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2449 1 #include 2 #include 3 const int N=520; 4 int vis[N][N],map[N][N]; 5 int n,m,cnt; 6 void dfs(int x,int y) 7 { 8 if (x==n&&y==m) 9 {10 cnt++;11 return ;12 }13 if (x-1>=1&&map[x-1][y]==0&&!vis[. 阅读全文
posted @ 2013-10-12 16:36
N_ll
阅读(175)
评论(0)
推荐(0)

浙公网安备 33010602011771号