AcDream 1079 郭氏数
生活随笔
收集整理的這篇文章主要介紹了
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; }?
總結
以上是生活随笔為你收集整理的AcDream 1079 郭氏数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: windows phone 快捷键
- 下一篇: Mongodb-初步了解