HDU 6441 费马大定理+勾股数

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define fillchar(a, x) memset(a, x, sizeof(a))
#define huan printf("\n")
#define debug(a,b) cout<<a<<" "<<b<<" "<<endl
#define ffread(a) fastIO::read(a)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+10,inf=0x3f3f3f3f;
int main()
{
    int T;
    scanf("%d", &T);
    while (T--)
    {
        ll n, a, b, c;
        scanf("%lld%lld", &n, &a);
        if (n == 1)
        {
            printf("%lld %lld\n", 1, 1+a);
        }
        else if (n == 2)
        {
            if (a % 2 == 1)
            {
                ll tmp = (a-1)/2;
                b = 2*tmp*tmp+2*tmp;
                c = b+1;
                printf("%lld %lld\n", b, c);
            }
            else
            {
                ll tmp = a/2 - 1;
                b = tmp*tmp + 2*tmp;
                c = b + 2;
                printf("%lld %lld\n", b, c);
            }
        }
        else
            printf("-1 -1 \n");
    }
    return 0;
}
勾股数https://wenku.baidu.com/view/8282f1b669eae009591bec85.html
posted @ 2018-10-17 22:24  灬从此以后灬  阅读(150)  评论(0编辑  收藏  举报