版本比较
ok
正文
增加 8 行删除 8 行
46 行未改动47484950515253545511 行未改动67686970717273747510 行未改动868788899091929394959697989910010110210310410510610710810911011111211311411511611711846 行未改动typedef long long lnt;#define inf 0x3f3f3f3f#define log(format, ...) printf(format, ##__VA_ARGS__)#define dg() printf("DEBUG on %3d ", __LINE__)using std::cin;using std::cout;11 行未改动void operator +=(const znt &a) { *this = *this + a; }znt operator *(const znt &a) const { return (lnt(v) * a.v) % mod; }void operator *=(const znt &a) { *this = *this * a; }znt operator -(const znt &a) const { return (v - a.v + mod) % mod; }void operator -=(const znt &a) { *this = *this - a; }};const znt inv6 = 166666668, inv2 = 500000004;10 行未改动znt S(lnt n) {lnt ed = sqrtl(n + 1) - 1;znt res = A(ed) + A(ed - 1) + B(ed - 1) + znt(2) * B(ed);if (pow2(ed + 1) - 1 != n) {res += (ed + 1) * (n - pow2(ed + 1) + 1);}return res;}znt solve() {lnt n; cin >> n;znt res = 0;for (lnt i = 1; pow3(i) <= n; ++i) { // \sqrt[3]{n}lnt l = pow3(i), r = std::min(pow3(i + 1) - 1, n);res += znt(i) * znt((S(r) - S(l - 1)));}return res;}int main() {printf("%d\n", solve());return 0;}```46 行未改动47484950515253545511 行未改动67686970717273747510 行未改动868788899091929394959697989910010110210310410510610710810911011111211311411511611711846 行未改动typedef long long lnt;#define inf 0x3f3f3f3f#define log(format, ...) printf(format, ##__VA_ARGS__)#define dg() printf("DEBUG on %3d ", __LINE__)using std::cin;using std::cout;11 行未改动void operator +=(const znt &a) { *this = *this + a; }znt operator *(const znt &a) const { return (lnt(v) * a.v) % mod; }void operator *=(const znt &a) { *this = *this * a; }znt operator -(const znt &a) const { return (v - a.v + mod) % mod; }void operator -=(const znt &a) { *this = *this - a; }};const znt inv6 = 166666668, inv2 = 500000004;10 行未改动znt S(lnt n) {lnt ed = sqrtl(n + 1) - 1;znt res = A(ed) + A(ed - 1) + B(ed - 1) + znt(2) * B(ed);if (pow2(ed + 1) - 1 != n) {res += (ed + 1) * (n - pow2(ed + 1) + 1);}return res;}znt solve() {lnt n; cin >> n;znt res = 0;for (lnt i = 1; pow3(i) <= n; ++i) { // \sqrt[3]{n}lnt l = pow3(i), r = std::min(pow3(i + 1) - 1, n);res += znt(i) * znt((S(r) - S(l - 1)));}return res;}int main() {printf("%d\n", solve());return 0;}```