uva 10104 Euclid Problem (数论-扩展欧几里德)
题目大意:
已知 A 和 B , 问你 A*X+B*Y=GCD(A,B)的 X,Y解。
解题思路:
非常裸的拓展欧几里德算法。
拓展欧几里德算法证明过程:
因为 B*X1+A%B*Y1=GCD(B,A%B) =GCD(A,B)=A*X+B*Y
所以 B*X1+(A-A/B*B)*Y1=A*X+B*Y
A*Y1+B*(X1-A/B*Y1)=A*X+B*Y
于是: X=Y1,Y=(X1-A/B*Y1)
因此,得出( A*...
分类:
其他好文 时间:
2014-05-26 05:53:55
阅读次数:
297
【题目】
Follow up for N-Queens problem.
Now, instead outputting board configurations, return the total number of distinct solutions.
【题意】
解N皇后问题,N-Queens要求返回所有的解,而本题只需要返回可行解的数目
【思路】
DFS,参考N-Queens...
分类:
其他好文 时间:
2014-05-25 01:51:55
阅读次数:
236
http://poj.org/problem?id=2449
大致题意:给出一个有向图,求从起点到终点的第K短路。
K短路A*算法讲解:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define LL long...
分类:
其他好文 时间:
2014-05-24 23:39:47
阅读次数:
352
题目如下:
Problem D: Hartals
A social research organization has determined a simple set of parameters to simulate the behavior of the political parties of our country. One of the ...
分类:
其他好文 时间:
2014-05-24 23:10:01
阅读次数:
317
Square Coins
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7748 Accepted Submission(s): 5238
Problem Description
People in Silverl...
分类:
其他好文 时间:
2014-05-24 21:06:18
阅读次数:
220
http://poj.org/problem?id=3013
题意:
Because of a technical difficulty, price of an edge will be (sum of weights of all descendant nodes) × (unit price of the edge).这句话一直没看懂。后面还以为是最小生成树。
正确...
分类:
其他好文 时间:
2014-05-24 20:27:13
阅读次数:
266
【题目】
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.
Given an integer n, return all distinct solutions to the n-queens puzzle.
Each solution contains a distinct board configuratio...
分类:
其他好文 时间:
2014-05-24 17:12:32
阅读次数:
237
原题:http://acm.timus.ru/problem.aspx?space=1&num=18261826. MinefieldTime
limit: 0.5 secondMemory limit: 64 MBTo fulfill an assignment, a
reconnaissance...
分类:
其他好文 时间:
2014-05-24 12:57:02
阅读次数:
282
http://acm.timus.ru/problem.aspx?space=1&num=18241824.
Ifrit BomberTime limit: 0.5 second Memory limit: 64 MBIn the six years that
passed since the fi...
分类:
其他好文 时间:
2014-05-24 11:46:13
阅读次数:
298
注意,条件:B>=C 。应考虑B=C的情况。#includeusing namespace
std;int A,B,C;void jugs(int a,int b,int C){ if(b==C) { cout=B) { a=A-(B-b...
分类:
其他好文 时间:
2014-05-24 09:34:19
阅读次数:
288