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

恳求帮忙,编译错误

Posted by c0500404081 at 2005-03-26 10:49:13 on Problem 1037
我的编译总是报错,而在本地的vs.net和dev c++上都是正常的。此外,对一些较小的数据都是可以通过的,我手头没有比较全面的测试数据,有人能提供吗?
附上我的代码,比较长,因为不太熟悉,手生:
#include<iostream>
using namespace std;
__int64 maxnum;
__int64 up[20][20],down[20][20];
struct condition_data;    
void creat_form(__int64 maxnum);   
void get_line(__int64 n,__int64 p,__int64 *line);

struct condition_data{
   __int64 n[21],p[21]; //n=the number of banisters;p=the serial number
};    

void creat_form(__int64 maxnum){//建立up,down两个表格
    __int64 pos,i,j;
    for(i=1;i<=maxnum;i++)
		for(j=1;j<=maxnum;j++){
			up[i][j]=0;
			down[i][j]=0;
		}
	up[1][1]=1;
    down[1][1]=1;
    for(pos=2;pos<=maxnum;pos++){
        for(i=1;i<=pos;i++){
            up[pos][i]=0;
            for(j=1;j<i;j++) up[pos][i]+=down[pos-1][j];         
            down[pos][i]=0;
            for(j=i;j<pos;j++) down[pos][i]+=up[pos-1][j];        
        }    
    }    
}        

void get_line(__int64 n,__int64 p,__int64 *line){//获取答案排列
    __int64 i,j;
    bool flag;
    j=1;
    while(p-up[n][j]-down[n][j]>0){
        p=p-up[n][j]-down[n][j];
		j++;
    }        
    *line=j;
    line++;
    if(p<=up[n][j]) 
		flag=false;
	else{
		p=p-up[n][j];
		flag=true;
	}
    for(i=n-1;i>1;i--){
       if(flag) {
		   j=*(line-1);
           while(p>up[i][j]&&j<=i){
                      p=p-up[i][j];
                      j++;    
           }
           flag=false;
       }    
       else {
		   j=1;
           while(p>down[i][j]&&j<*(line-1)){
                       p=p-down[i][j];
                       j++;
            }
           flag=true; 
       }             
       *line=j;
       line++;
    }    
    *line=1;
}    

void output(__int64 *line,__int64 n){//将上面排列还原为正常数据并输出
    bool is_get[21];
    __int64 i,o_line[21];
    for(i=1;i<=n;i++) is_get[i]=false;
    __int64 j;
    for(i=1;i<=n;i++){
            o_line[i]=1;
            while(is_get[o_line[i]]) o_line[i]++;
            j=1;
            while(j<*line||is_get[o_line[i]]){
                 if(is_get[o_line[i]]==false)j++;
                 o_line[i]++;       
            }   
        is_get[o_line[i]]=true;  
		line++;
    }        
    cout<<o_line[1];
    for(i=2;i<=n;i++){
        cout<<" "<<o_line[i];
    }    
	cout<<"\n";
}    

void main(){
    __int64 total;
    cin>>total;
    __int64 i;
    maxnum=0;
    condition_data condition;
    for(i=0;i<total;i++){
        cin>>condition.n[i]>>condition.p[i];
        if (maxnum<condition.n[i]) maxnum=condition.n[i];
    }    
    creat_form(maxnum);
    __int64 *line;
    for(i=0;i<total;i++){
        line=new __int64[condition.n[i]];
        get_line(condition.n[i],condition.p[i],line);
        output(line,condition.n[i]);
        delete line;
    }    
	system("pause");
}     




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