| ||||||||||
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 |
郁闷!!用个STL竟然遇到了罕见的Memory Limit Exceeded ,这是什么状况?#include <iostream> #include <cstdio> #include <cstring> #include <queue> using namespace std; typedef struct { int num[101]; int n; }Point; Point ans; int n; void bfs(int x) { queue<Point> q; Point p0,p1,p2; p0.num[0]=1;p0.n=1; q.push(p0); while(!q.empty()) { p1=q.front();q.pop(); int temp=0; for(int i=0;i<p1.n;i++) temp = (temp*10+p1.num[i])%n; for(int i=0;i<2;i++) { p2=p1;p2.num[p2.n]=i;p2.n+=1; int temp1=(temp*10+i)%n; if(temp1==0){ ans=p2; while(!q.empty()) q.pop(); return; } q.push(p2); } } } int main(){ while(~scanf("%d",&n)) { if(n==0) break; bfs(n); for(int i=0;i<ans.n;i++) printf("%d",ans.num[i]); printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator