zoukankan      html  css  js  c++  java
  • AcDream 1079 郭氏数

    题意:求出两点的距离。

    解法:由于有一种情况相加将超出long long的最大表示范围,由于计算机将减法都视作是加法,因此溢出之后的值如果使用无符号格式控制符来输出的话,结果是对的。

    代码如下:

    #include <iostream>
    #include <cstring>
    #include <cstdlib>
    #include <cstdio>
    #include <algorithm>
    using namespace std;
    
    int main() {
        int T;
        scanf("%d", &T);
        while (T--) {
            long long int x, y, Max, Min;
            scanf("%lld %lld", &x, &y);
            Max = x > y ? x : y;
            Min = x < y ? x : y; 
            printf("%llu\n", Max - Min);
        }
        return 0;
    }
  • 相关阅读:
    Spock
    Spock
    Spock
    Spock
    Spock
    Spock
    Python3 与 Python2 的不同
    python 文件处理
    Django 数据迁移
    Python 特殊方法
  • 原文地址:https://www.cnblogs.com/Lyush/p/2969575.html
Copyright © 2011-2022 走看看