CodeForces - 707C

Posted 发牌员

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeForces - 707C相关的知识,希望对你有一定的参考价值。

让我们铭记勾股数,1,2无勾股数,大于等于3的奇数:2n+1勾股数是2*n*n+2*n,2*n*n+2*n+1,大于等于3的偶数:2n为n*n+1,n*n-1。啊,gtmd勾股数!

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n;
int main()
{
    scanf("%lld",&n);
    if(n==1||n==2) printf("-1\n");
    else
    {   int flag=0;
        if((n-1)%2==0)
        {   ll m=(n-1)/2;
            printf("%lld %lld\n",2*m*m+2*m,2*m*m+2*m+1);
            flag=1;
        }
        else if(n%2==0)
        {
            ll m=n/2;
            printf("%lld %lld\n",m*m-1,m*m+1);
            flag=1;
        }
        if(!flag) printf("-1\n");
    }
    return 0;
}

 

以上是关于CodeForces - 707C的主要内容,如果未能解决你的问题,请参考以下文章

Pythagorean Triples CodeForces - 707C 推理题,大水题

[Codeforces Round #522 (Div. 2, based on Technocup 2019 Elimination Round 3)][C. Playing Piano](代码片段

c_cpp Codeforces片段

Codeforces 86C Genetic engineering(AC自动机+DP)

CodeForces 1005D Polycarp and Div 3(思维贪心dp)

(Incomplete) Codeforces 394 (Div 2 only)