版本比较
题解:P15794 【MX-J28-T1】「Cfz Round 8」Sqrt Problem
正文
增加 4 行删除 4 行
3 行未改动456788910111216 行未改动2930313233333435363713 行未改动51525354555655565758596071 行未改动3 行未改动2. $ \sqrt{n}$### 再看大小直接循环时 k 竟然能达到 $$ 10^{18} $$## 依旧暴力(60 分)```cpp line-numbers lines=5-6 ```cpp line-numbers lines=5-6#include <bits/stdc++.h>using namespace std;#define ll long longll c,t,n,k;16 行未改动 if (r * r == c) { ans += 1; c = r; } } else { ll c2 = ceil(sqrt(c)); if (c2 % 2 != c % 2) {13 行未改动## 优化仔细看,仔细思考1. n 在经过开方之后会迅速地减小,n 很小时直接套公式2. 二分开方,避免浮点误差 ```cpp line-numbers lines=5-6
```cpp line-numbers lines=5-6#include <bits/stdc++.h>using namespace std;using ll = long long ;ll c,t,n,k;71 行未改动