sqrt
的精度范围支持到 9e15
左右
更大的精度要求需要 sqrtl
测试代码:
#include <bits/stdc++.h>
using namespace std;
const int Max = 1e9, Rg = 10, Block = 1e6;
int main() {
for(int i = 1; i <= 10; ++i) {
if(i % Block == 0) cerr << "Ok: Block " << i / Block << endl;
for(int j = -Rg; j <= Rg; ++j) {
int k = sqrtl(1ll * i * i + j);
if(k == i && j < 0) cerr << "Waring: " << i << " " << j << endl;
if(k < i && j >= 0) cerr << "Waring: " << i << " " << j << endl;
}
}
// Waring from 94906266 -1
}
long long
一般可以存下 9*mod*mod
大小的数,
unsigned long long
一般可以存下 18*mod*mod
大小的数
当累积的数大多较小,但有部分是 long long
范围时,可以考虑如下代码:
const long long L = 8e18;
void TryMod(long long &s, const int p) { if(s <= -L || s >= L) s %= p; }
标签:const,实现,东西,long,int,1e6,一些,精度,mod
From: https://www.cnblogs.com/JerryTcl/p/17218082.html