社区讨论

有人知道这是什么原理吗?

学术版参与者 7已保存回复 9

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
9 条
当前快照
1 份
快照标识符
@migrbavw
此快照首次捕获于
2025/11/27 09:30
3 个月前
此快照最后确认于
2025/11/28 15:31
3 个月前
查看原帖
A+B problem:
CPP
extern"C" int getchar();
extern"C" int putchar(int);
namespace myfastio{
	class istream{
		bool ex,pre;
	public:
		istream&operator>>(int&x){
			if(pre)ex=true;
			x=0;
			if(pre)return*this;
			int f=1;
			char c=getchar();
			while(!(48<=c&&c<58)){if(!(~c)){pre=true;return*this;}if(c=='-')f*=-1;c=getchar();}
			while(48<=c&&c<58){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
			x=x*f;
			if(!(~c)){pre=true;return*this;}
			return*this;
		}
		istream&operator>>(long&x){
			if(pre)ex=true;
			x=0;
			if(pre)return*this;
			int f=1;
			char c=getchar();
			while(!(48<=c&&c<58)){if(!(~c)){pre=true;return*this;}if(c=='-')f*=-1;c=getchar();}
			while((48<=c&&c<58)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
			x=x*f;
			if(!(~c)){pre=true;return*this;}
			return*this;
		}
		istream&operator>>(long long&x){
			if(pre)ex=true;
			x=0;
			if(pre)return*this;
			int f=1;
			char c=getchar();
			while(!(48<=c&&c<58)){if(!(~c)){pre=true;return*this;}if(c=='-')f*=-1;c=getchar();}
			while((48<=c&&c<58)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
			x=x*f;
			if(!(~c)){pre=true;return*this;}
			return*this;
		}
		istream&operator>>(unsigned int&x){
			if(pre)ex=true;
			x=0;
			if(pre)return*this;
			int f=1;
			char c=getchar();
			while(!(48<=c&&c<58)){if(!(~c)){pre=true;return*this;}if(c=='-')f*=-1;c=getchar();}
			while(48<=c&&c<58){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
			x=x*f;
			if(!(~c)){pre=true;return*this;}
			return*this;
		}
		istream&operator>>(long unsigned int&x){
			if(pre)ex=true;
			x=0;
			if(pre)return*this;
			int f=1;
			char c=getchar();
			while(!(48<=c&&c<58)){if(!(~c)){pre=true;return*this;}if(c=='-')f*=-1;c=getchar();}
			while((48<=c&&c<58)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
			x=x*f;
			if(!(~c)){pre=true;return*this;}
			return*this;
		}
		istream&operator>>(long long unsigned int&x){
			if(pre)ex=true;
			x=0;
			if(pre)return*this;
			int f=1;
			char c=getchar();
			while(!(48<=c&&c<58)){if(!(~c)){pre=true;return*this;}if(c=='-')f*=-1;c=getchar();}
			while((48<=c&&c<58)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
			x=x*f;
			if(!(~c)){pre=true;return*this;}
			return*this;
		}
		istream&operator>>(char&c){
			if(pre)ex=true;
			if(pre)return*this;
			c=getchar();
			while(c<=32||c==127){if(!(~c)){pre=true;return*this;}c=getchar();}
			return*this;
		}
		istream&operator>>(float&x){
			if(pre)ex=true;
			x=0;
			if(pre)return*this;
			int f=1;
			char c=getchar();
			while(!(48<=c&&c<58)){if(!(~c)){pre=true;return*this;}if(c=='-')f*=-1;c=getchar();}
			while(48<=c&&c<58){x=x*10+(c-48);c=getchar();}
			if(c=='.'){
				c=getchar();
				double pos=1e-1;
				while(48<=c&&c<58){x=pos*(c-48);c=getchar();pos*=1e-1;}
			}
			x=x*f;
			if(!(~c)){pre=true;return*this;}
			return*this;
		}
		istream&operator>>(double&x){
			if(pre)ex=true;
			x=0;
			if(pre)return*this;
			int f=1;
			char c=getchar();
			while(!(48<=c&&c<58)){if(!(~c)){pre=true;return*this;}if(c=='-')f*=-1;c=getchar();}
			while(48<=c&&c<58){x=x*10+(c-48);c=getchar();}
			if(c=='.'){
				c=getchar();
				double pos=1e-1;
				while(48<=c&&c<58){x=pos*(c-48);c=getchar();pos*=1e-1;}
			}
			x=x*f;
			if(!(~c)){pre=true;return*this;}
			return*this;
		}
		istream&operator>>(long double&x){
			if(pre)ex=true;
			x=0;
			if(pre)return*this;
			int f=1;
			char c=getchar();
			while(!(48<=c&&c<58)){if(!(~c)){pre=true;return*this;}if(c=='-')f*=-1;c=getchar();}
			while(48<=c&&c<58){x=x*10+(c-48);c=getchar();}
			if(c=='.'){
				c=getchar();
				double pos=1e-1;
				while(48<=c&&c<58){x=pos*(c-48);c=getchar();pos*=1e-1;}
			}
			x=x*f;
			if(!(~c)){pre=true;return*this;}
			return*this;
		}
	#ifdef _GLIBCXX_STRING
		istream&operator>>(std::string&s){
			if(pre)ex=true;
			if(pre)return*this;
			char c;
			*this>>c;
			while(!(c<=32||c==127)){s+=c,c=getchar();}
			if(!(~c))pre=true;
			return*this;
		}
	#endif
		bool ok(){return!ex;}
	}cin;
	class Setprecision{
	public:
		int precision;
	};
	Setprecision setprecision(int pre){return{pre};}
	class ostream{
		long double precision;
	public:
		ostream(){precision=1e-6;}
		ostream&operator<<(int x){
			if(x<0)putchar('-'),x=-x;
			if(x>9)*this<<x/10;
			putchar(x%10+'0');
			return*this;
		}
		ostream&operator<<(long x){
			if(x<0)putchar('-'),x=-x;
			if(x>9)*this<<x/10;
			putchar(x%10+'0');
			return*this;
		}
		ostream&operator<<(long long x){
			if(x<0)putchar('-'),x=-x;
			if(x>9)*this<<x/10;
			putchar(x%10+'0');
			return*this;
		}
		ostream&operator<<(unsigned int x){
			if(x>9)*this<<x/10;
			putchar(x%10+'0');
			return*this;
		}
		ostream&operator<<(long unsigned int x){
			if(x>9)*this<<x/10u;
			putchar(x%10+'0');
			return*this;
		}
		ostream&operator<<(long long unsigned int x){
			if(x>9)*this<<x/10;
			putchar(x%10+'0');
			return*this;
		}
		ostream&operator<<(char c){
			putchar(c);
			return*this;
		}
		ostream&operator<<(float x){
			if(x<0)putchar('-'),x=-x;
			*this<<(long long unsigned int)x;
			x-=(long long unsigned int)x;
			putchar('.');
			for(long double i=1e-1;i>=(precision>1e-6?precision:1e-6);i*=1e-1){
				int val=(x+precision)/i;
				putchar(val+'0');
				x-=val*i;
			}
			return*this;
		}
		ostream&operator<<(double x){
			if(x<0)putchar('-'),x=-x;
			*this<<(long long unsigned int)x;
			x-=(long long unsigned int)x;
			putchar('.');
			for(long double i=1e-1;i>=(precision>1e-15?precision:1e-15);i*=1e-1){
				int val=(x+precision)/i;
				putchar(val+'0');
				x-=val*i;
			}
			return*this;
		}
		ostream&operator<<(long double x){
			if(x<0)putchar('-'),x=-x;
			*this<<(long long unsigned int)x;
			x-=(long long unsigned int)x;
			putchar('.');
			for(long double i=1e-1;i>=(long double)(precision>1e-20?precision:1e-20);i*=1e-1){
				int val=(x+precision)/i;
				putchar(val+'0');
				x-=val*i;
			}
			return*this;
		}
		ostream&operator<<(Setprecision prec){
			int p=prec.precision;
			precision=1;
			while(p--){
				precision*=1e-1;
			}
			return*this;
		}
	#ifdef _GLIBCXX_STRING
		ostream&operator<<(std::string s){
			for(int i=0;i<s.size();i++)*this<<s[i];
			return*this;
		}
	#endif
	}cout;
}
using namespace myfastio;
int a,b;
int main(){
	cin>>a>>b;
	cout<<a+b;
	return 0;
}

回复

9 条回复,欢迎继续交流。

正在加载回复...