摘要:
解法一:记录下标#include <stdio.h>
#include<iostream>
using namespace std; #define N 10001
int a[N]; int main()
{ int n,max,start,end; while(cin>>n && n) { max=0x80000000; int sum=0; int tempStart=1; for(int i=1;i<n +1;i++) { scanf("%d",&a[... 阅读全文
随笔分类 - ACM
搬寝室 1421
2012-05-31 23:54 by java线程例子, 217 阅读, 收藏,
摘要:
#include <iostream>
#include <algorithm>
using namespace std;
#define Min(a,b) (a < b ? a : b)
#define INF 2100000000
int dp[2001][1001];//第一个下标(2001)是指
int main() { int n;//物品的个数 int k;//取多少对 int a[2001];//数组a先用来各个物品的质量,再用来保存平方差。 int i;//行 int j;//列 while(scanf("%d%d", & 阅读全文
ACM入门之杭电1045:Fire Net C++解法
2012-03-31 01:31 by java线程例子, 265 阅读, 收藏,
摘要:
Fire Net地址:http://acm.hdu.edu.cn/showproblem.php?pid=1045Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2957Accepted Submission(s): 1700Problem DescriptionSuppose that we have a square city with straight streets. A map of a city is a square board 阅读全文
八(N)皇后问题的C++实现
2012-03-22 12:10 by java线程例子, 327 阅读, 收藏,
摘要:
简单说:任意两个皇后(国际象棋)都不能处于同一行、同一列或同一斜线上。C++代码实现如下:#include <iostream>
using namespace std;
//isPlace()用于判断会不会跟之前已放置的皇后互相攻击,
int count = 0;
bool isPlace(int *a, int k){ for(int i = 0; i < k; ++i){ //a[i] == a[k]:同一列上 //(a[i] + i == a[k] + k)【向左斜】 和 (a[i] - i == a[k] - k)【向右斜】 :同一斜线上 if((a[i] == a 阅读全文