HDU-6441 Find Integer

 1 #include <iostream>
 2 #include <stdlib.h>
 3 #include <string>
 4 #include <vector>
 5 #include <algorithm>
 6 
 7 using namespace std;
 8 int main()
 9 {
10     int T;
11     scanf("%d",&T);
12     while(T--)
13     {
14         long long int n,a;
15         scanf("%lld %lld",&n,&a);
16         if(n==0||n>2)
17         {
18             printf("-1 -1\n");
19         }
20         else if(n==1)
21         {
22             printf("%lld %lld\n",1,a+1);
23         }
24         else if((a&0x1)==1)
25         {
26             long long int b,c;
27             long long tmp = (a-1)/2;
28             b = 2*tmp*(tmp+1);
29             c = 2*tmp*(tmp+1)+1;
30             printf("%lld %lld\n",b,c);
31         }
32         else
33         {
34             long long int b,c;
35             long long tmp = a/2-1;
36             b = tmp*tmp+2*tmp;
37             c = tmp*tmp+2*tmp+2;
38             printf("%lld %lld\n",b,c);
39         }
40     }
41     return 0;
42 }

 

posted @ 2018-08-25 17:47  Asurudo  阅读(400)  评论(0编辑  收藏  举报