New Document
 
 

Study more & AC more

2007-7-6 18:54:00
sudoku
这个搜索算法不是很有效率 一时还想不出来什么好方法  放假了再说
#i nclude <stdio.h>
#i nclude <string.h>

int over;
int p, sud[10][10];
int stack[82][2];
int r[10][10], c[10][10], s[10][10];

int f(int i, int j)
{
	i = (i-1)/3;
	j = (j-1)/3+1;
	return i*3+j;
}

void output()
{
	int i, j;
	
	for(i = 1; i <= 9; i++)
	{
		for(j = 1; j <= 9; j++)
			printf("%d",sud[i][j]);
		printf("\n");
	}
}

void solve(int n)
{
	int i, j, k;
	int F, tmp[9];

	i = stack[n][0], j = stack[n][1];
	F = 0;
	for(k = 1; k <= 9; k++)
	{
		if(r[i][k]==0&
……
nickname | 阅读全文 | 回复 | 引用通告
2007-6-6 15:15:00
8数码 POJ 1077
写了一个晚上构造出来的 刷新了最长代码的记录 还刷出了个内存-4K  C语言 头一回见
# include <stdio.h>

int pos[9][2];
int pz[3][3];
char tmp[10][2];

void up()
{
	printf("u");
	pos[0][0]--;
	pz[pos[0][0]+1][pos[0][1]] = pz[pos[0][0]][pos[0][1]];
	pz[pos[0][0]][pos[0][1]] = 0;
	pos[pz[pos[0][0]+1][pos[0][1]]][0]++;
}

void down()
{
	printf("d");
	pos[0][0]++;
	pz[pos[0][0]-1][pos[0][1]] = pz[pos[0][0]][pos[0][1]];
	pz[pos[0][0]][pos[0][1]] = 0;
	pos[pz[pos[0][0]-1][pos[0][1]]][0]--;
}

void left()
{
	printf("l");
	pos[0][1]--;
	pz[pos[0][
……
nickname | 阅读全文 | 回复 | 引用通告
2007-5-20 22:43:00
季后赛
太阳队虽然输了,可是还是值得称赞!
永远支持太阳,支持Nash!!
nickname | 阅读全文 | 回复 | 引用通告
2007-5-19 15:34:00
POJ 1087
刚刚学二分 不过一看这个还是网络流
不过转化了一下
代码是老师写的 我的写错了  不知道错在哪里
# include <stdio.h>
# include <string.h>

#define VMAX 500
#define PMAX 500
#define CL 30

int n, d, k, no;
char plug[PMAX][CL];
int mapade[PMAX][PMAX],dev[VMAX];

void warshall()
{
int i, j, m;

for(i = 0; i < no; i++)
{
for(j = 0; j < no; j++)
if(mapade[j][i])
for(m = 0; m < no; m++)
if(mapade[i][m])mapade[j][m]=1;
}
}


int addplug(char p
……
nickname | 阅读全文 | 回复 | 引用通告
2007-5-12 11:22:00
POJ 3178 Roping the Field
一个比较常见的 dp吧
code by 20053565
# include <stdio.h>
# include <math.h>
# include <stdlib.h>

int N, G;
double R;
int valid[151][151];
long dp[151][151];
struct node
{
	double x;
	double y;
}p[151];

struct Node
{
	double x;
	double y;
}c[151];

int check(int i, int j)
{
	int q;
	double A, B, C, D, E;

	for(q = 0; q < G; q++)
	{
		A = p[j].x-p[i].x; B = p[i].y-p[j].y; C = p[j].y*p[i].x-p[i].y*p[j].x;
		D = (A*c[q].y+B*c[q].x+C);
		E = A*A*c[q].x-B*C-A*B*c[q].y;
		if(D*D<=R*R*(A*A+B*B))
		{
			if((c[q].x-p[i].x
……
nickname | 阅读全文 | 回复 | 引用通告
2007-5-10 12:37:00
POJ 3222 Edge Pairing

官方解析

Problem E: Edge Pairing

A simple undirected graph with an even number of edges can always have its edges grouped into incident pairs. Below is a proof by construction.

Let r be some vertex in the graph. We grow a depth-first search tree T rooted at r.

Since the graph is connected, T actually spans every vertex.

We then construct the pairing bottom up,  starting from the leaves.

We mark all edges connecting a leave and its parent as unpaired.


……
nickname | 阅读全文 | 回复 | 引用通告
2007-5-8 17:15:00
POJ 3201 Little Quilt
RE了数N次 才过的, 但是在本机上始终未能运行成功,无奈之下交之,AC.  RP again!!
code by 20053565
source Colombia 2006

……
nickname | 阅读全文 | 回复 | 引用通告
2007-5-8 17:05:00
POJ 3198 Polygon Encoder
这个题是我迄今最长的代码......
离散课本 第四章函数 f(i,j) = (i+j)*(i+j+1)/2+j;
令u = f(i,j);
令A = [(sqrt(1+8*u)-1)/2](取整数部分)
则j = u-A*(A+1)/2;i = A-j;
用到了高精度的开方 还用到了凸多边形的面积公式 之前以为这个公式只有在所有顶点按顺时针排序后才适用.
可是没排序也能的出结果,只是符号的差异,不知是巧合还是......
听说java里的Biginteger用于高精度很爽,下学期就要学了,期待ing.
(手动开方部分angelpin指点)
code by 20053565

……
nickname | 阅读全文 | 回复 | 引用通告
2007-5-7 10:41:00
POJ 3171 Cleaning Shifts
老师的想法:
. 将顶点设在相邻的两秒之间:(0 0 1)对应的边为 (0 1 1)
nickname | 阅读全文 | 回复 | 引用通告
2007-5-7 10:32:00
POJ 3168 Barn Expansion
苦想之后还是TLE......
经fzk大牛指点才800+MS飘过
大牛说:"按(x,y)将所有顶点排序,扫描一边,看看每条竖着的边的两个顶点排序后是否相邻
再按(y,x)排序,再扫描一边";
感谢所有帮助过我的大牛们......
Code By 20053565

……
nickname | 阅读全文 | 回复 | 引用通告
首页 上一页 下一页 尾页 页次:1/2页  10篇日志/页 转到:
时间记忆
<<  < 2007 - >  >>
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
我的相册
最新日志
最新评论
最新回复
我的好友
处理 SSI 文件时出错
站点信息
  • 日志:2
  • 评论:2
  • 留言:2
  • 访问:
 
Powered by Oblog.