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 |
为什么是WA? 代码附上!初学C,写得不好!!! #include"stdio.h" int i,j; long a[100],b[100]; void f(long a,long b) { int temp,k; long aa,bb; aa=a;bb=b; temp=aa*(aa+1)/2; if(bb<=temp) { for(k=1;;k++) { if(bb-k<=0) break; bb-=k; } i=bb; j=a-k+bb; } else//与上面得if是对称的 { bb=aa*aa+1-bb; for(k=1;;k++) //与 { //上 if(bb-k<=0) //面 break; //的 bb-=k; //方 } //法 i=bb; //相 j=a-k+bb; //同 i=a+1-i; j=a+1-j; } return; } void main() { int k,n; scanf("%d",&n); for(k=1;k<=n;k++) { scanf("%d %d",&a[k],&b[k]); } for(k=1;k<=n;k++) { f(a[k],b[k]);//找出指定位置得二维下标(i,j) printf("%ld\n",i*i+100000*i+j*j-100000*j+i*j); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator