黑书上说用二分图的知识来解,但我想不出来,只好找规律发现,一条柱时为1,两条柱时为4。三条柱时为8。。这些1,3,7,11的数字加1后,都是下一条柱的最底部的数字,而且一条柱的数字之和总是按照这样的规律。1^2,2^2,3^2,4^2......所以。。 1 #include 2 #include....
分类:
其他好文 时间:
2014-06-29 00:32:08
阅读次数:
294
自己之前的不见了。。这题是双向广搜即可过。。 1 // Colour Hash (色彩缤纷游戏) 2 // PC/UVa IDs: 110807/704, Popularity: B, Success rate: average Level: 3 3 // Verdict: Accepted ...
分类:
其他好文 时间:
2014-06-28 20:42:53
阅读次数:
194
LINQ TO SQL 实现无限递归查询现总结一下,希望能给以后再碰到此类问题的朋友一些帮助--构造测试数据: 只作演示用CREATE TABLE [dbo].[Tim_LinqTable]([Id] int PRIMARY KEY IDENTITY(1,1) NOT NULL,[Name] [va...
分类:
数据库 时间:
2014-06-21 13:26:29
阅读次数:
217
这题有点类似LIS,由于颜色最多100种,所以只需建立一个100的数组,按对立面的关系以某种颜色为向上面的最大值就可以了。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int cube[505][7]; 7 int ...
分类:
其他好文 时间:
2014-06-21 12:58:02
阅读次数:
244
题目连接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=247&page=show_problem&problem=3666137646221225Digit CountingAccepte...
分类:
其他好文 时间:
2014-06-21 10:53:16
阅读次数:
365
简单题 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int MAX=205; 7 const int inf=1000000; 8 int tim[MAX][MAX]; 9 char maze[MAX][...
分类:
其他好文 时间:
2014-06-21 00:34:49
阅读次数:
226
Description
The Broken Pedometer
The Problem
A marathon runner uses a pedometer with which he is having problems. In the pedometer the symbols are represented by seven s...
分类:
其他好文 时间:
2014-06-18 12:31:09
阅读次数:
203
就是判断一个数是否是素数,网上很多版本,我觉得都有点问题,今天一个朋友问我这个问题,我才知道,现在我就贴出自己的代码,很有用哦!!
#include
#include
int Prime(unsigned int a)
{
unsigned int i;
int k=0;
if (a==1) k=1;
else for(i=2;i
if(a%...
分类:
编程语言 时间:
2014-06-18 07:30:59
阅读次数:
210
分治法的典例
当练手了
神奇的是,使用inplace_merge按说应该是O(n)的算法,但是用sort nlogn的算法反而更快
先上快排版
#include
#include
#include
#include
#include
using namespace std;
const int SIZE = 10000+10;
const double INF = 1...
分类:
其他好文 时间:
2014-06-18 07:17:22
阅读次数:
170
UVA 10090 - Marbles
题目链接
题意:有两种盒子,一种代价c1,能装n1个珠子,一种代价c2,能装n2个珠子,问如何正好装n个珠子,并且使得代价最少。
思路:利用扩展欧几里得算法求出n1?x+n2?y=n的一个解(x′,y′)
就可以知道x,y的通解分别为
x=x′?n/gcd(n1,n2)+n2/gcd(n1,n2)?t
y=y′?n/gac(n1,n2)?...
分类:
其他好文 时间:
2014-06-18 00:44:40
阅读次数:
182