@wc022 https://ykj.cpolar.cn/article/7187
@wc022 wait,我在 try to write a solution to the problem。
@CPP
问了豆包,他在int mian(){}前面加了一段这么长的代码:
istream& operator>>(istream& is, __int128& num) { string s; is >> s; // 先读入字符串(避免直接处理__int128的IO) num = 0; bool is_negative = false; int i = 0; // 处理负号 if (s[0] == '-') { is_negative = true; i = 1; } // 字符串转__int128 for (; i < s.size(); ++i) { num = num * 10 + (s[i] - '0'); } if (is_negative) num = -num; return is; } // 2. 重载__int128的输出运算符(cout << __int128) ostream& operator<<(ostream& os, __int128 num) { // 处理0的特殊情况 if (num == 0) { os << "0"; return os; } // 处理负数 if (num < 0) { os << "-"; num = -num; } // __int128转字符串(逆序存再反转) string s; while (num > 0) { s.push_back(num % 10 + '0'); num /= 10; } reverse(s.begin(), s.end()); // 反转后得到正确顺序 os << s; return os; }
我去,__int128有39位数,超过了数据范围!!!
可是是像int那样直接定义吗?
看来这题评黄没评高。
CPP出的题还是太难了
@wc022 你们都不知道这世界上有一个东西,叫做 __int128 吗?
@CPP 还是太权威了
是的喽QAQ
我也不会,因为要用高精度乘法加高精度加法且还要多个数相乘相加
共 13 条回复
@wc022 https://ykj.cpolar.cn/article/7187
@wc022 wait,我在 try to write a solution to the problem。
@CPP
问了豆包,他在int mian(){}前面加了一段这么长的代码:
我去,__int128有39位数,超过了数据范围!!!
可是是像int那样直接定义吗?
看来这题评黄没评高。
CPP出的题还是太难了
@wc022 你们都不知道这世界上有一个东西,叫做 __int128 吗?
@CPP 还是太权威了
是的喽QAQ
我也不会,因为要用高精度乘法加高精度加法且还要多个数相乘相加