本机测试RE,重载运算符一个数都读不进去
查看原帖
本机测试RE,重载运算符一个数都读不进去
135999
老官童鞋gogo楼主2022/11/22 17:44

代码如下:(前面的超长命名空间可以不用看)

#include<bits/stdc++.h>
using namespace std;
namespace Fast{
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define int128 __int128
#define uint128 unsigned __int128
#define Ld long double
#define space putchar(' ')
#define enter putchar('\n')
#define PI acos(-1)
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<"\n"
#define inf 1000000000
#define INF 1000000000000000000
#define N 1010
#define M 1000010
	template<class T>inline bool read(T &x){
		x=0;char c=getchar();bool f=0;
		while(!isdigit(c)){if(c==EOF)return false;f^=c=='-',c=getchar();}
		while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
		if(f)x=-x;
		return true;
	}
	template<typename T>inline void print(T x){
		int s[65],top=0;
		if(x<0)putchar('-'),x=~x+1;
		while(x)s[++top]=x%10,x/=10;
		if(!top)s[++top]=0;
		while(top)putchar(s[top--]+'0');
	}
	template<class T>inline bool readd(T &x){
		ll X=0;double y=1.0;char c=getchar();bool f=0;
		while(!isdigit(c)){if(c==EOF)return false;f^=c=='-',c=getchar();}
		while(isdigit(c))X=(X<<3)+(X<<1)+(c^48),c=getchar();
		x=X;
		if(c!='.'&&c!='E'&&c!='e'){if(f)x=-x;return true;}
		if(c=='.'){c=getchar();while(isdigit(c))x+=(y/=10)*(c^48),c=getchar();}
		if(f)x=-x;
		X=0;f=0;
		if(c=='E'||c=='e'){
			c=getchar();
			while(!isdigit(c)){if(c==EOF)return true;f^=c=='-',c=getchar();}
			while(isdigit(c))X=(X<<3)+(X<<1)+(c^48),c=getchar();
		}
		if(f)for(ll i=1;i<=X;i++)x/=10;
		else for(ll i=1;i<=X;i++)x*=10;
		return true;
	}
	template<class T>inline void printd(T x,int y){
		static ll mul[]={1};
		for(ll i=1;i<=18;i++)
			mul[i]=(mul[i-1]<<3)+(mul[i-1]<<1);
		if(x<-1e-12)putchar('-'),x=-x;
		x*=mul[y];
		ll x1=(ll)round(x),x2=x1/mul[y],x3=x1-x2*mul[y];
		print(x2);
		if(y>0){
			putchar('.');
			for(ll i=1;i<y&&x3*mul[i]<mul[y];putchar('0'),i++);
			print(x3);
		}
	}
	template<class T>inline bool readc(T &x){
		char c=getchar();
		while(c==' '||c=='\n'||c=='\r'||c=='\t')c=getchar();
		if(c==EOF)return false;
		x=c;
		return true;
	}
	template<class T>inline void printc(T x){putchar(x);}
	template<class T>inline bool readcc(T *x){
		char c=getchar();
		while(c==' '||c=='\n'||c=='\r'||c=='\t')c=getchar();
		if(c==EOF)return false;
		while(c!=' '&&c!='\n'&&c!='\r'&&c!='\t'&&c!=EOF)*x++=c,c=getchar();
		*x=0;
		return true;
	}
	template<class T>inline void printcc(T *x){while(*x)putchar(*x++);}
	template<class T>inline bool reads(T &x){
		x="";char c=getchar();
		while(c==' '||c=='\n'||c=='\r'||c=='\t')c=getchar();
		if(c==EOF)return false;
		while(c!=' '&&c!='\n'&&c!='\r'&&c!='\t'&&c!=EOF)x+=c,c=getchar();
		return true;
	}
	template<class T>inline void prints(T x){for(ll i=0;x[i]!='\0';i++)putchar(x[i]);}
	template<class T,class ...S>inline bool read(T &x,S &...y){return read(x)&&read(y...);}
	template<class T,class ...S>inline bool readd(T &x,S &...y){return readd(x)&&readd(y...);}
	template<class T,class ...S>inline bool readc(T &x,S &...y){return readc(x)&&readc(y...);}
	template<class T,class ...S>inline bool readcc(T *x,S *...y){return readcc(x)&&readcc(y...);}
	template<class T,class ...S>inline bool reads(T &x,S &...y){return reads(x)&&reads(y...);}
	template<class T,class ...S>inline void print(T x,S ...y){print(x),putchar(' '),print(y...);}
	template<class T,class ...S>inline void printd(T x,S ...y){printd(x),putchar(' '),printd(y...);}
	template<class T,class ...S>inline void printc(T x,S ...y){printc(x),putchar(' '),printc(y...);}
	template<class T,class ...S>inline void printcc(T *x,S *...y){printcc(x),putchar('\n'),printcc(y...);}
	template<class T,class ...S>inline void prints(T x,S ...y){prints(x),putchar('\n'),prints(y...);}
	const double eps=1e-7;
	template<typename T>inline T Abs(T x){return x>0?x:-x;}
	template<typename T>inline T Max(T x,T y){return x>y?x:y;}
	template<typename T>inline T Min(T x,T y){return x<y?x:y;}
	template<typename T>inline T Fabs(T x){return x>eps?x:-x;}
	template<typename T>inline T Fmax(T x,T y){return x-y>eps?x:y;}
	template<typename T>inline T Fmin(T x,T y){return x-y<eps?x:y;}
}
using namespace Fast;
ll n,K,mod=inf+7;
struct matrix{
	ll m[N][N];
	matrix(){
		memset(m,0,sizeof(m));
	}
	void matrix_read(){
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				read(m[i][j]);
		return;
	}
	void matrix_print(){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				print(m[i][j]);
				space;
			}
			enter;
		}
		return;
	}
}a,ans;
matrix operator *(const matrix &x,const matrix &y){
	matrix c;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++)
				c.m[i][j]=(c.m[i][j]+x.m[i][k]*y.m[k][j])%mod;
	return c;
}
matrix matrix_pow(matrix x,int num){
	matrix pow_ans;
	memset(pow_ans.m,0,sizeof(pow_ans.m));
	for(int i=1;i<=n;i++)	pow_ans.m[i][i]=1;
	while(num){
		if(num&1)	pow_ans=pow_ans*x;
		x=x*x;
		num>>=1;
	}
	return pow_ans;
}
int main(){
	//	freopen("a.out","r",stdin);
	//	freopen("a.out","w",stdout);
	read(n,K);
	a.matrix_read();
	ans=matrix_pow(a,K);
	ans.matrix_print();
	return 0;
}
2022/11/22 17:44
加载中...