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 fml4d1 at 2020-10-07 21:50:23 on Problem 1426
#include<iostream>
using namespace std;

struct Node{
	int data;
	int p;
	int pre;
	Node():pre(0){
	}
};
struct que{
	Node a[10009];
	int s;
	int e;
};
int n;
que q;
void print(int w){
    if(w==0){
      cout<<q.a[0].data;
      return;
    }
    else{
    	print(q.a[w].p);
        cout<<q.a[w].data;
    }
}
void bfs(){
  q.s=0;
  q.e=0;
  q.a[q.s].data=1;
  q.a[q.s].p=-1;
  q.e++;
  while(q.s!=q.e){
  	Node f=q.a[q.s];
    int k=f.data+f.pre*10;
    f.pre=k%n;
	if(!f.pre){
		print(f.p);
		cout<<f.data<<endl;
		return ;
	}
	else{
	  q.a[q.e].data=1;
	  q.a[q.e].p=q.s;
	  q.a[q.e].pre=f.pre;
	  q.e++;
	  q.a[q.e].data=0;
	  q.a[q.e].p=q.s;
	  q.a[q.e].pre=f.pre;
	  q.e++;	
	}
	q.s++;	  
  }
}
int main()
{
	while(1){
		cin>>n;
		if(n==0)
		break;
		else
			bfs();
	}
	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