Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0
Special Judge


Problem Description
people in USSS love math very much, and there is a famous math problem .

give you two integers n.
 

 

Input
one line contains one integer )
 

 

Output
print two integers );

else print two integers -1 -1 instead.
 

 

Sample Input
1 2 3
 

 

Sample Output
4 5
 
分析:根据费马大定理:n>2时无解
  只要考虑n=0,1,2
  n=0时,无解
  n=1时,随意构造两个数满足a+b=c
  n=2时,随意构造一组勾股数满足a*a+b*b=c*c
AC代码:
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define ls (r<<1)
#define rs (r<<1|1)
#define debug(a) cout << #a << " " << a << endl
using namespace std;
typedef long long ll;
const ll maxn = 1e6+10;
const ll mod = 998244353;
const double pi = acos(-1.0);
const double eps = 1e-8;
int main() {
    ios::sync_with_stdio(0);
    ll T;
    scanf("%lld",&T);
    while( T -- ) {
        ll n, a, b, c;
        scanf("%lld%lld",&n,&a);
        if( n >= 3 || n == 0 ) {
            printf("-1 -1\n");
        }
        else if( n == 1 ) {
            printf("1 %lld\n",a+1);
        }
        else {
            ll h = 1;
            while( a%2 == 0 ) {
                a = a/2;
                h = h*2;
            }
            ll s, t;
            s = a;
            t = 1;
            b = (s*s-t*t)/2;
            c = (s*s+t*t)/2;
            b = b*h;
            c = c*h;
            printf("%lld %lld\n",b,c);
        }
     }
    return 0;
}

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-21
相关资源
相似解决方案