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 <iostream> #define maxsize 50000001 using namespace std; int main() { long a[maxsize],b[maxsize]; a[0]=0; b[0]=0; b[1]=2; long j=1,k=1; for(long i=1;i<=maxsize;i++) { if(j==b[k]) { j++; k++; } a[i]=j; b[i]=j+i; j++; } while(1) { long ax,bx,term; cin>>ax>>bx; if(ax>bx) { term=ax; ax=bx; bx=term; } int f=1; for(long i=0;ax>=a[i];i++) { if(ax==a[i] && bx==b[i]) { f=0; break; } } cout<<f<<endl; } return 0; } 好像是数组太大了,汗 这题的意思就是把 1 2 3 5 4 7 6 10 8 13 9 15 ··· 这些全都保存起来,再来判断 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator