• 矩阵乘的优先级问题


    Miemeng发现的问题

     这个用嘴说不清楚~~

    上码!

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 #define N 222
     5 using namespace std;
     6 const int Mod=2009;
     7 struct JZ{
     8     int lines,cols;
     9     int A[N][N];
    10     JZ(){
    11         lines=cols=0;
    12         memset(A,0,sizeof A);
    13     }
    14     void set_JZ(int l,int c){
    15         lines=l,cols=c;
    16     }
    17     void out(){
    18         for (int i=1;i<=lines;i++){
    19             for (int j=1;j<=cols;j++){
    20                 printf("%d ",A[i][j]);
    21             }
    22             puts("");
    23         }
    24     }
    25 };JZ a,b;
    26 int n,tim;
    27 JZ operator * (JZ a,JZ b){
    28     JZ c;
    29     c.lines=min(a.lines,b.lines),c.cols=min(a.cols,b.cols);
    30     int len=a.lines+b.lines-c.lines;
    31     for (int i=1;i<=c.lines;i++){
    32         for (int j=1;j<=c.cols;j++){
    33             for (int k=1;k<=len;k++){
    34                 c.A[i][j]+=a.A[i][k]*b.A[k][j];
    35                 c.A[i][j]%=Mod;
    36             }
    37         }
    38     }
    39     return c;
    40 }
    41 JZ ppow(JZ a,int b){
    42     JZ ans;ans.set_JZ(9*n,9*n);
    43     for (int i=0;i<9*n;i++){
    44         ans.A[i][i]=1;
    45     }
    46     while(b){
    47         if(b&1)ans=ans*a;
    48         a=a*a;
    49         b>>=1;
    50     }
    51     return ans;
    52 }
    53 inline bool ian(const char ch){
    54     if(ch>='0'&&ch<='9')return 1;
    55     return 0;
    56 }
    57 char st[22];
    58 int main(){
    59     (a.in()*b*in()).out();
    60     a.in(),b.in(),(a*b).out();//这里两行输出不同QAQ
    61     return 0;
    62 }

    事实上:(Updated)

    它仿佛会先输入b,再输入a,从而使用了矩阵中不成立的交换律。呜呜呜~~~

    不是我调出来的~~

    没了

  • 相关阅读:
    48 个seo技巧,seo站长必知技巧
    如何提高网站排名经验分享
    SEO影响网站排名因素有哪些
    如何建立一个利于SEO的网站
    HTML 笔记之 HTML 元素的概念
    idea配置springboot项目记录
    课后作业(一)
    团队任务(一)
    团队任务(二)
    软工假期预习作业1
  • 原文地址:https://www.cnblogs.com/marmot-cage/p/11209835.html
Copyright © 2020-2023  润新知