@[慕蓉樱雪](/user/234074)
[我博客里有,您自行观看。](https://www.luogu.com.cn/blog/ljyljyljy/du-ru-du-chu-you-hua)
by LJY_ljy @ 2020-02-24 23:30:43
@[慕蓉樱雪](/user/234074) double建议用cin或者是scanf
by LJY_ljy @ 2020-02-24 23:31:05
怎么都不一样啊(到底该用哪个)
by 樱雪喵 @ 2020-02-24 23:31:35
```cpp
inline int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x*f;
}
```
~~位运算似乎也许更快~~
by ztxtjz @ 2020-02-24 23:33:43
@[ztxtjz](/user/225965) 假的,位运算优化没有本质区别,还是比fread慢的多。
by Marser @ 2020-02-24 23:43:07
短小精悍fread
```cpp
char buf[999999],*p1,*p2;
#define G (p1==p2?(p2=(p1=buf)+fread(buf,1,999991,stdin),*p1++):*p1++)
inline int in(int&x){bool f=0;char c=G;for(x=0;c<'0'||c>'9';c=G)if(c=='-')f=1;for(;c>='0'&&c<='9';c=G)x=x*10+c-48;if(f)x=-x;}
```
by panyf @ 2020-02-24 23:44:41
@[慕蓉樱雪](/user/234074) 都可以啊,您随便。
by LJY_ljy @ 2020-02-24 23:52:58
@[慕蓉樱雪](/user/234074)
```
inline int read(){
register int x=0,v=1,ch=getchar();
while(!isdigit(ch)){if(ch=='-')v=-1;ch=getchar();}
while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^'0');ch=getchar();}
return x*v;
}
```
by Lates @ 2020-02-24 23:57:24
~~mmap呢~~
by SSerxhs @ 2020-02-25 00:03:48
```cpp
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
struct io_t {
struct stat st;
char* ptr;
int fd;
io_t() {
fd = fileno(stdin), fstat(fd, &st), ptr = (char*)mmap(0, st.st_size, 1, 2, fd, 0);
}
inline io_t& operator>>(int& x) {
x = 0;
int f = 1;
while (!isdigit(*ptr))
if (*ptr++ == '-') f = -1;
while (isdigit(*ptr)) x = x * 10 + *ptr++ - 48;
x *= f;
return *this;
}
} io;
```
by tiger0133 @ 2020-02-25 00:07:27