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

用scanf()和printf() 就ac了 用cin cout 就wa了 为什么呀????

Posted by qqyukuilong at 2009-08-26 22:09:48 on Problem 1157
#include <iostream>
#include<vector>
using namespace std;
class aesthetic_values
{
public:
	void input();
	void solve();
private:
	vector<int*> values;
	int MAX(int,int);
	int F,V,Size;
};
void aesthetic_values::input()
{
	int i,j,a,i1=0,j1;
	//cin>>F>>V;
	scanf("%d%d",&F,&V);
	Size=V+1-F;
	values.assign(F,(int *)NULL);
	for(i=0;i<F;i++)
	{
		values[i]=new int[Size];
	}
	for(i=0;i<F;i++)
	{
		int t=V+1-F;
		j1=0;
		for(j=0;j<V;j++)
		{
			//cin>>a;
			scanf("%d",&a);
			if(j>=i&&t--)
			{
				values[i1][j1++]=a;
			}
		}
		i1++;
	}
}
int aesthetic_values::MAX(int a,int b)
{
	int j,t,max=-9999999;
	for(j=b;j>=0;j--)
	{
        t=values[a-1][j]+values[a][b];
		if(t>max)
		{
			max=t;
		}
	}
	return max;
}
void aesthetic_values::solve()
{
	int i,j,k=-9999999;
	for(i=1;i<F;i++)
	{
		for(j=0;j<Size;j++)
		{
			values[i][j]=MAX(i,j);
		}
	}
	for(i=0;i<Size;i++)
	{
		if(values[F-1][i]>k)
		{
			k=values[F-1][i];
		}
	}
	//cout<<k<<endl;
	printf("%d",k);
}
int main()
{
	aesthetic_values bb;
	bb.input();
	bb.solve();
	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