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!!!!!!!!,北大的大牛们看看!!!#include <iostream.h> #include <stdio.h> #include <math.h> _int64 n ; long total=0; _int64 counter; long ans; long a[10000]; long dd[10000]; long i , j , k ; bool could (long d) { _int64 a, b , c; if ((6*n) % d !=0) return false; _int64 k; k = (6*n) / d; a=6; b=(6*d+6); c=(2*d*d+3*d+1-k); if (b*b<4*a*c) return false; ans = long ((-b+sqrt(b*b-4*a*c))/2/a); if (a*ans*ans+b*ans+c==0) return true; return false; } void out() { printf("%ld\n",total); for (i=total; i>=1; i--) { printf("%ld ",dd[i]); for (j=1;j<=dd[i]-1; j++) {printf("%ld ",a[i]+j);} printf("%ld\n" , a[i]+dd[i]); } } void work() { long d; _int64 k; counter=0; total=0; for (d=1; (counter<=n-d*d) ; d++) { if (could(d)) { total++ ; a[total]=ans; dd[total]=d; } k=d; counter=counter+k*k; } //printf("%d\n",d); // if (total>2) out(); } int main() { scanf("%I64d",&n); // for (n=800000; n<=1000000; n++) {work();} return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator