如何防止EOF卡快读
  • 板块学术版
  • 楼主summer_summer
  • 当前回复12
  • 已保存回复12
  • 发布时间2021/10/13 19:44
  • 上次更新2023/11/4 03:54:08
查看原帖
如何防止EOF卡快读
222889
summer_summer楼主2021/10/13 19:44

最近打模拟赛,一个毒瘤数据卡快读,用下面这个程序尝试把ch==-1的数量输出一下,发现输都输不完,输出的tot都到几十亿了还是没有结束,只能用cin了吗?

#include<bits/stdc++.h>
#define inf 0x7fffffff
#define ll long long
using namespace std;
const int C=1000000007;
const int N=500100;
int m,n,a[N],tot;
char Getchar()
{
	char ch=getchar();
	if(ch==-1)
	{
		tot++;
		if(tot%1000000==0) cout<<tot<<endl;//
	}
	return ch;
}
long long read()
{
	long long f = 1, x = 0;
	char ch = Getchar();
	while (ch < '0' || ch > '9')
	{
		if (ch == '-') f = -1;
		ch = Getchar();
	}
	while (ch >= '0' && ch <= '9')
	{
		x = x * 10 + ch - '0';
		ch = Getchar();
	}
	x *= f;
	return x;
}
int main()
{
	freopen("btsc6.in","r",stdin);
    m=read();
	n=read();
    for(int i=1;i<=m;i++)
	{
		a[i]=read();
	}
    cout<<tot<<endl;
	return 0;
}
2021/10/13 19:44
加载中...