日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

1065 A+B and C (64bit) (20 分)【难度: 简单 / 思维 高精度】

發布時間:2025/3/20 编程问答 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 1065 A+B and C (64bit) (20 分)【难度: 简单 / 思维 高精度】 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


https://pintia.cn/problem-sets/994805342720868352/problems/994805406352654336
方法一: 用高精度的板子寫一下是可以的,不過因為有正負號,故得分類討論,實屬復雜。
方法二: 直接用long double 來計算

#include<bits/stdc++.h> using namespace std; int main(void) {int t; cin>>t;for(int i=1;i<=t;i++){long double a,b,c; cin>>a>>b>>c;if(a+b>c) printf("Case #%d: true\n",i);else printf("Case #%d: false\n",i);}return 0; }

方法三: 直接用__int128來計算
因為__int128不能直接的讀入,故得自己寫一個讀入的函數,這里直接用p云大佬的代碼。

#include <iostream> using namespace std; template <typename T> inline T read() {T sum = 0, fl = 1;int ch = getchar();for (; !isdigit(ch); ch = getchar())if (ch == '-')fl = -1;for (; isdigit(ch); ch = getchar())sum = sum * 10 + ch - '0';return sum * fl; } int main() {int n;cin >> n;for (int i = 1; i <= n; i++){__int128_t a, b, c;a = read<__int128_t>(), b = read<__int128_t>(), c = read<__int128_t>();if (a + b > c) cout << "Case #" << i << ": true" << endl;else cout << "Case #" << i << ": false" << endl;} }

總結

以上是生活随笔為你收集整理的1065 A+B and C (64bit) (20 分)【难度: 简单 / 思维 高精度】的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。