Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这道题目的数据是不是弱了?这样爆搞也是0ms

Posted by 10041112acmer at 2013-08-19 15:50:46 on Problem 3782
代码:
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <functional>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <bitset>
#include <stack>
#include <ctime>
#include <list>
using namespace std;

int main(){
     int p, m, d[10010];
     int i, j, z, minsum, sum;
     scanf("%d", &p);
	while(p--){
         scanf("%d%d", &z, &m);
	for (i=0; i<m; i++) scanf("%d", d+i);
	for (i=0, minsum=0; i<m; i++){
	minsum+=d[i];
	for (j=i+1, sum=0; j<m; j++){
	sum+=d[j];
	if (sum>minsum) break;
	if (sum==minsum) sum=0;
	}
	if (j==m && sum==0) break;
	}
	printf("%d %d\n", z, minsum);
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator