欢迎访问我的个人网站==》 jiashubing.cn

HDU 4627 The Unsolvable Problem(简单题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4627

题目大意:给定一个整数n(2 <= n <= 109),满足a+b=n并且[a,b]的最小公倍数最大。

分析:相当简单的的一道题,因为生病好久没做题目,杭电居然是要用__int64,用long long反而错误,为此,WA了无数遍

代码如下:

 1 # include<iostream>
 2 # include<cstdio>
 3 # include<cmath>
 4 using namespace std;
 5 __int64 n;
 6 int main()
 7 {
 8     int T;
 9     scanf("%d",&T);
10     while(T--)
11     {
12         scanf("%I64d",&n);
13         __int64 temp = n/2;
14         if(n==2)
15             printf("1\n");
16         else if(n%2==1)
17             printf("%I64d\n",temp*(temp+1));
18         else
19         {
20             if(temp%2){
21                 printf("%I64d\n",(temp-2)*(temp+2));
22             }
23             else
24                 printf("%I64d\n",(temp-1)*(temp+1));
25         }
26     }
27     return 0;
28 }

 

posted @ 2013-08-02 09:44  贾树丙  阅读(229)  评论(0编辑  收藏  举报