问题:给定两个正整数,计算这两个数的最小公倍数并写出算法。Input输入包含多组测试数据,每组只有一行,包括两个不大于1000的正整数.Output对于每个测试用例,给出这两个数的最小公倍数,每个实例输出一行。Sample Input10 14Sample Output70回答:#include ....
分类:
其他好文 时间:
2015-05-12 11:11:50
阅读次数:
94
#include using namespace std;#define N 100int A[N]; static int n; void Initial(){ cout > n; cout > A[i]; }}void Print(){ cout 1) ...
分类:
编程语言 时间:
2015-05-12 11:07:52
阅读次数:
213
题意:tsp问题,但是每个点可以最多走两次链接:点我转移方程见代码#include#include#include#includeusing namespace std;#define inf 0x3f3f3f3fint State[12];int vis[60000][12];int dp[600...
分类:
其他好文 时间:
2015-05-12 11:07:45
阅读次数:
120
http://poj.org/problem?id=3581这题说是给了N个数字组成的序列A1 A2 ..An 其中A1 大于其他的数字 , 现在要把序列分成三段并将每段分别反转求最小字典序以后还是老老实实用基数排序 用sort wa 了 一晚#include #include #include #...
分类:
编程语言 时间:
2015-05-12 10:55:00
阅读次数:
245
1、 由于是有序数组,log(n)的时间查找最小值的index1.1 一定要注意当m、r、l三个位置相同值时,无法区分左右了,所以需要在l到r区间遍历找到最小元素。2、 看最小值index的左右两侧,是否查找值落在 [l,i] 与 [i,r] 上,在对应区间上进行二分查找 1 #include 2 ...
分类:
编程语言 时间:
2015-05-12 10:46:45
阅读次数:
124
#include
#include
using namespace std;
struct treeNode
{
int value;
treeNode* left;
treeNode* right;
treeNode* parent;
};//节点结构
void insert(treeNode **root,int value)
{
treeNode* ...
分类:
其他好文 时间:
2015-05-12 09:36:45
阅读次数:
121
// 期望输出str = hello world 的两种方法
#include
char *GetStr(char **p)
{
*p = "hello word";
return *p;
}
int main()
{
char *str = NULL;
if (NULL != GetStr(&str))
{
printf(" str = %s\n",str);
}
r...
分类:
编程语言 时间:
2015-05-12 09:35:45
阅读次数:
155
#include
using namespace std;
//new 的本质还是malloc delete 的本质是free
//delete new 最底层就是free malloc
//delete new 提供了重载的机制(官方说法),通俗的理解就是劫持
//delete new 全局重载,只要分配内存都劫持
//内存防泄漏系统,内存反复释放,进制创建,禁止销毁
//dele...
分类:
其他好文 时间:
2015-05-12 09:34:45
阅读次数:
122
#include
#include
#include
#include
using namespace std;
const int maxn = 1000005;
int h[maxn], q[maxn];
int buffer[10];
void scan_d(int &x) {
char ch = getchar();
while(!isdigit(ch)) ch = g...
分类:
其他好文 时间:
2015-05-12 09:31:47
阅读次数:
146
1.ans=max(全为a的最大矩阵,全为b的最大矩阵,全为c的最大矩阵)
2.代码:
#include
#include
#include
using namespace std;
const int INF=1<<30;
char mat[1005][1005];
int a[1005][1005];
int b[1005][1005];
int c[1005][1005];
int L...
分类:
其他好文 时间:
2015-05-12 09:30:36
阅读次数:
134