| ||||||||||
| 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 | |||||||||
好人看看哪个数据不对.郁闷#include<stdio.h>
#define MAX 102
int flags[MAX+1][(MAX+1)*MAX/2]={0};
int main()
{
int i,j,k;
for(i =1;i<=MAX;i++)
{
flags[i][0] =i+1;
for(j =1;j<i;j++)
{
for(k =0;k<=(i-j)*(i-j-1)/2;k++)
{
if(flags[i][j*(i-j)+k]<flags[i-j][k]+(i-j+1)*j)
flags[i][j*(i-j)+k]=flags[i-j][k]+(i-j+1)*j;
}
}
}
k=1;
while(scanf("%d %d",&i,&j)&&(i+j))
{
if(flags[i][j])
printf("Case %d: %d lines with exactly %d crossings can cut the plane into %d pieces at most.\n",k,i,j,flags[i][j]);
else printf("Case %d: %d lines cannot make exactly %d crossings.\n",k,i,j);
k++;
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator