摘要:
向量(Vector)在几乎所有的几何问题中,向量(有时也称矢量)是一个基本点。向量的定义包含方向和一个数(长度)。在二维空间中,一个向量可以用一对x和y来表示。例如由点(1,3)到(5,1的向量可以用(4,-2)来表示。这里大家要特别注意,我这样说并不代表向量定义了起点和终点。向量仅仅定义方向和长度。向量加法向量也支持各种数学运算。最简单的就是加法。我们可以对两个向量相加,得到的仍然是一个向量。我们有: V1(x1, y1)+V2(x2, y2)=V3(x1+x2, y1+y2)下图表示了四个向量相加。注意就像普通的加法一样,相加的次序对结果没有影响(满足交换律),减法也是一样的。点乘(Dot 阅读全文
摘要:
使用stringstream对象简化类型转换C++标准库中的提供了比ANSI C的更高级的一些功能,即单纯性、类型安全和可扩展性。在本文中,我将展示怎样使用这些库来实现安全和自动的类型转换。为什么要学习如果你已习惯了风格的转换,也许你首先会问:为什么要花额外的精力来学习基于的类型转换呢?也许对下面一个简单的例子的回顾能够说服你。假设你想用sprintf()函数将一个变量从int类型转换到字符串类型。为了正确地完成这个任务,你必须确保证目标缓冲区有足够大空间以容纳转换完的字符串。此外,还必须使用正确的格式化符。如果使用了不正确的格式化符,会导致非预知的后果。下面是一个例子:int n=10000 阅读全文
摘要:
// 大数的四则运算及求模。数字无位数限制,除法的商支持小数。 #include #include #include using namespace std; class BIGINTEGEROPERATIONS { private: static int COMPARE(string number1, string number2) { int j; int length1 = number1.size(); ... 阅读全文
摘要:
诡异的楼梯Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 5111Accepted Submission(s): 1170Problem DescriptionHogwarts正式开学以后,Harry发现在Hogwarts里,某些楼梯并不是静止不动的,相反,他们每隔一分钟就变动一次方向.比如下面的例子里,一开始楼梯在竖直方向,一分钟以后它移动到了水平方向,再过一分钟它又回到了竖直方向.Harry发现对他来说很难找到能使得他最快到达目的地的路线 阅读全文
摘要:
What Are You Talking AboutTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 102400/204800 K (Java/Others)Total Submission(s): 7555Accepted Submission(s): 2341Problem DescriptionIgnatius is so lucky that he met a Martian yesterday. But he didn't know the language the Martians use. The Martian 阅读全文
摘要:
NightmareTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4360Accepted Submission(s): 2177Problem DescriptionIgnatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get 阅读全文
摘要:
Ignatius and the Princess ITime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7141Accepted Submission(s): 2137Special JudgeProblem DescriptionThe Princess has been abducted by the BEelzebub feng5166, our hero Ignatius has to rescue our pretty Princess 阅读全文
摘要:
Prime Ring ProblemTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 14061Accepted Submission(s): 6390Problem DescriptionA ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of nu 阅读全文
摘要:
SafecrackerTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4682Accepted Submission(s): 2327Problem Description=== Op tech briefing, 2002/11/02 06:42 CST ==="The item is locked in a Klein safe behind a painting in the second-floor library. Klei 阅读全文
摘要:
杭电10101.奇偶性剪枝可以把map看成这样:010101101010010101101010010101从为0的格子走一步,必然走向为1的格子从为1的格子走一步,必然走向为0的格子即:0->1或1->0必然是奇数步0->0走1->1必然是偶数步所以当遇到从0走向0但是要求时间是奇数的,或者,从1走向0但是要求时间是偶数的都可以直接判断不可达![cpp]view plaincopy#include#include#includecharmap[9][9];intn,m,t,di,dj;boolescape;intdir[4][2]={{0,-1},{0,1},{1,0 阅读全文