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 maoqi at 2005-12-19 16:43:28 on Problem 1320
#include<stdio.h>
#include<math.h>
__int64 result[11][2];
__int64 absolute( __int64 a){
         if(a<0) return -a;
         else    return  a;
         }
         
int check(__int64 a,int n,__int64 b){
     int i;
     if(!a) return 0;
     for(i=0;i<=n;i++)
       if(a==result[i][0]) return 0;
     if(a>b) return 0;
     else    return 1;
     }
     
int main(){
    __int64 min,temp1,temp2;
    int i,j,m;
    m=0;
    result[0][0]=1;  result[0][1]=3;
    while(m<11){        
       min=2*result[m][0]*result[m][1];        
       for(i=0;i<=m;i++)
         for(j=0;j<=i;j++)
            { temp1=absolute(result[i][0]*result[j][1]-result[j][0]*result[i][1]);
              temp2=result[i][0]*result[j][1]+result[j][0]*result[i][1];         
             if(check(temp1,m,min)) min=temp1;
             if(check(temp2,m,min)) min=temp2;
             }
       result[++m][0]=min;
       result[m][1]=sqrt((8*min*min+1));
                   }
    for(i=1;i<=10;i++)
      printf("%10.I64d%10.I64d\n",result[i][0],(result[i][1]-1)/2);
     }  

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