HDU 6441 费马大定理+勾股数
Posted stranger-
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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(" ") #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 ", 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 ", b, c); } else { ll tmp = a/2 - 1; b = tmp*tmp + 2*tmp; c = b + 2; printf("%lld %lld ", b, c); } } else printf("-1 -1 "); } return 0; }
勾股数https://wenku.baidu.com/view/8282f1b669eae009591bec85.html
以上是关于HDU 6441 费马大定理+勾股数的主要内容,如果未能解决你的问题,请参考以下文章
2018CCPC网络赛 1004Find Integer(勾股数+费马大定理)