本文共 2240 字,大约阅读时间需要 7 分钟。
10120 12 34 56 7
00 12 1
//mod3为0的话这个可以优化 跳过循环 //别人的代码 对如果存在很多0的矩阵可以变快/* #include#include #include using namespace std;int a[808][808];int b[808][808];int ans[808][808];int main(){ int n; while (~scanf("%d",&n)) { for (int i=1;i<=n;i++) for (int t=1;t<=n;t++) { scanf("%d",&a[i][t]); a[i][t]%=3; } for (int i=1;i<=n;i++) for (int t=1;t<=n;t++) { scanf("%d",&b[i][t]); b[i][t]%=3; } for (int i=1;i<=n;i++) for (int t=1;t<=n;t++) ans[i][t]=0; for (int i=1;i<=n;i++) for (int k=1;k<=n;k++) { if (a[i][k]==0) continue ; for (int t=1;t<=n;t++) ans[i][t]+=a[i][k]*b[k][t]; } for (int i=1;i<=n;i++) { printf("%d",ans[i][1]%3); for (int t=2;t<=n;t++) printf(" %d",ans[i][t]%3); printf("\n"); } }}*/ //但是本代码是使用减少Mod求余的次数 也可以过 1750MS #include #include #include using namespace std;const int N=800+10;int A[N][N],B[N][N],re[N][N];int n;inline void handle(){ int i,j,z; for(i=0;i #include #include using namespace std;const int N=800+10;int A[N][N],B[N][N],re[N][N];int n;inline void handle(){ int i,j,z; for(i=0;i
转载地址:http://vfmvi.baihongyu.com/