2003年南海初中 面积最大

题目

这里写图片描述


解题思路

“数论”

这里写图片描述


代码

#include<cstdio>
#include<cmath>
#define file(x) freopen(#x".in","r",stdin);freopen(#x".out","w",stdout)
using namespace std; 
int n,a,b; double te1,te2,te,ans; 
int main()
{
    scanf("%d",&n); 
    for (int i=1;i<=2*n-1;i++)
     for (int j=1;j<=2*n-1;j++)
     {
         te1=sqrt(n*n-(i/2.0)*(i/2.0))*2; 
         te2=sqrt(n*n-(j/2.0)*(j/2.0))*2; 
         te=te1*i+te2*j-i*j;    
         if (te>ans)
          {
            ans=te; 
            a=i; b=j; 
         }
     }
    printf("%d\n",a); 
    printf("%d",b);
}

猜你喜欢

转载自blog.csdn.net/qq_39897867/article/details/80374241