1. 程式人生 > >HDU 6441 費馬大定理+勾股數

HDU 6441 費馬大定理+勾股數

code == aid sizeof html end deb using mes

#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

HDU 6441 費馬大定理+勾股數