快读TLE,算法没问题,绝了
查看原帖
快读TLE,算法没问题,绝了
364027
The_BJX楼主2021/5/4 11:24

真是绝了 鄙人无知不知道怎么写EOF跳出所以写了一个快读。。

前四个点TLE第五个点AC 真是绝了

#include <iostream>
#include <cstdio>
#define ll unsigned long long
using namespace std;
ll n;
ll sum=0;
ll qpow(ll a, ll b)
{
	ll base = 1;
	while(b)
	{
		if(b&1)
		{
			base*=a;
		}
		b>>=1;
		a*=a;
	}
	return base;
}

bool read()
{
	ll ans=0;
	ll f=1;
	char c;
	c=getchar();
	if(c=='EOF')
	{
		return false;
	}
	if(c=='-')
	{
		f=-1;
		c=getchar();
	}
	while(c!=' ')
	{
		if(c=='EOF')
		{
			sum+=ans;
			return false;
		}
		ans*=10;
		ans+=c-'0';
		c=getchar();
	}
	sum*=f;
	sum+=ans;
}

int main()
{
	int i=0;
	while(read()){i++;}
	cout << sum*qpow(2,i);
}

求大佬帮忙

2021/5/4 11:24
加载中...