萌新没学过数论,看题解自己打了一遍,求救。

P3811 【模板】模意义下的乘法逆元

@[hepta_lhd](/user/182691) 可以啊?noip可以,CSP也可以啊?
by Smile_Cindy @ 2020-03-06 18:03:42


我NOIp和CSP都是这么用的,而且,没爆过
by Smile_Cindy @ 2020-03-06 18:04:35


@[Alpha](/user/87058) 关同步流太慢了? 加上这几十行 ```cpp const int SZ = 1 << 23 | 233; struct FILEIN { char qwq[SZ], *S = qwq, *T = qwq, ch; #ifdef __WIN64 #define GETC getchar #else char GETC() { return (S == T) && (T = (S = qwq) + fread(qwq, 1, SZ, stdin), S == T) ? EOF : *S++; } #endif FILEIN& operator>>(char& c) {while (isspace(c = GETC()));return *this;} FILEIN& operator>>(string& s) {while (isspace(ch = GETC())); s = ch;while (!isspace(ch = GETC())) s += ch;return *this;} Tp<class T> void read(T& x) { bool sign = 0;while ((ch = GETC()) < 48) sign ^= (ch == 45); x = (ch ^ 48); while ((ch = GETC()) > 47) x = (x << 1) + (x << 3) + (ch ^ 48); x = sign ? -x : x; }FILEIN& operator>>(int& x) { return read(x), *this; } FILEIN& operator>>(ll& x) { return read(x), *this; } } in; struct FILEOUT {const static int LIMIT = 1 << 22 ;char quq[SZ], ST[233];int sz, O; ~FILEOUT() { flush() ; }void flush() {fwrite(quq, 1, O, stdout); fflush(stdout);O = 0;} FILEOUT& operator<<(char c) {return quq[O++] = c, *this;} FILEOUT& operator<<(string str) {if (O > LIMIT) flush();for (char c : str) quq[O++] = c;return *this;} Tp<class T> void write(T x) {if (O > LIMIT) flush();if (x < 0) {quq[O++] = 45;x = -x;} do {ST[++sz] = x % 10 ^ 48;x /= 10;} while (x);while (sz) quq[O++] = ST[sz--]; }FILEOUT& operator<<(int x) { return write(x), *this; } FILEOUT& operator<<(ll x) { return write(x), *this; } } out; ``` 速度堪比fread(雾)
by 1saunoya @ 2020-03-06 18:06:01


@[Isaunoya](/user/96580) 我拒绝(
by SisconHL @ 2020-03-06 18:06:41


最好还是scan f print f罢 ci n cou t关闭流同步可能会引发奇怪的故障...(也有可能是我太菜了不知道原理是啥吧)
by _WA自动机 @ 2020-03-06 18:07:21


@[Alpha](/user/87058) 爆炸了,CE了
by SisconHL @ 2020-03-06 18:09:15


@[_WA自动机](/user/48711) 这个我知道。。和缓冲区有关 就是必须自己刷新缓冲区,问题不大
by SisconHL @ 2020-03-06 18:10:03


@[hepta_lhd](/user/182691) 第一行加在头文件下方,剩下的加在main()开头freopen之后。
by Smile_Cindy @ 2020-03-06 18:10:21


@[Alpha](/user/87058) 没有ios这个命名空间
by SisconHL @ 2020-03-06 18:11:18


@[hepta_lhd](/user/182691) 用bits库
by Smile_Cindy @ 2020-03-06 18:12:47


上一页 | 下一页