zoukankan      html  css  js  c++  java
  • HDU

     关于 k1 k2 互质的问题,可以自己手动证明一下,需要一点数学直觉。

    #pragma warning(disable:4996)
    
    #include<iostream>
    #include<algorithm>
    #include<bitset>
    #include<tuple>
    #include<unordered_map>
    #include<fstream>
    #include<iomanip>
    #include<string>
    #include<cmath>
    #include<cstring>
    #include<vector>
    #include<map>
    #include<set>
    #include<list>
    #include<queue>
    #include<stack>
    #include<sstream>
    #include<cstdio>
    #include<ctime>
    #include<cstdlib>
    #define pb push_back
    #define INF 0x3f3f3f3f
    #define inf 0x7FFFFFFF
    #define moD 1000000003
    #define pii pair<ll,ll>
    #define eps 1e-8
    #define equals(a,b) (fabs(a-b)<eps)
    #define bug puts("bug")
    #define re  register
    #define fi first
    #define se second
    typedef  long long ll;
    typedef unsigned long long ull;
    const ll MOD = 1e6 + 7;
    const int maxn = 3e5 +5;
    const double Inf = 10000.0;
    const double PI = acos(-1.0);
    using namespace std;
    
    ll gcd(ll a, ll b) {
        return b == 0 ? a : gcd(b, a % b);
    }
    
    
    
    int main() {
        ll a, b, x, y;
        while (~scanf("%lld %lld", &a, &b)) {
            ll g = gcd(a, b);
            if (a * a - 4 * g * b < 0) {
                puts("No Solution");
                continue;
            }
            ll del = sqrt(a * a - 4 * g * b);
            x = (del + a) / 2;
            y = a - x;
            if (x / gcd(x, y) * y != b) {
                puts("No Solution");
                continue;
            }
            if (x > y) swap(x, y);
            printf("%lld %lld
    ", x, y);
        }
    }
  • 相关阅读:
    监控里的主码流和子码流是什么意思
    监控硬盘容量计算
    一个能让你了解所有函数调用顺序的Android库
    电工选线
    oracle linux dtrace
    list all of the Oracle 12c hidden undocumented parameters
    Oracle Extended Tracing
    window 驱动开发
    win7 x64 dtrace
    How to Use Dtrace Tracing Ruby Executing
  • 原文地址:https://www.cnblogs.com/hznumqf/p/13394204.html
Copyright © 2011-2022 走看看