| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
用scanf()和printf() 就ac了 用cin cout 就wa了 为什么呀????#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator