Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

矩阵WA的:一定要注意取模的问题

Posted by hzoi2017_csm at 2018-05-21 14:50:29 on Problem 3233
inline void Read(Mat &A){
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			scanf("%d",&A.a[i][j]);
			A.a[i][j]%=m;
		}
}
在读入的时候要记得取个模
否则会WA

inline void Print(Mat &A){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i==j)A.a[i][j+n]--;
			// while(A.a[i][j+n]<0)A.a[i][j+n]+=m;
                        //在这里取不取模均可,(虽然不取模会导致出现负数)
			if(j==1)printf("%d",A.a[i][j+n]);
			else printf(" %d",A.a[i][j+n]);
		}
		printf("\n");
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator