1 solutions

  • 0
    @ 2025-11-5 19:21:23

    C++ :

    #include<stdio.h>
    #include<math.h>
    #include<string.h>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    int a[6][4];
    int main()
    {
        int x,y,ans;
        while(scanf("%d%d%d",&x,&y,&ans)!=EOF)
        {
            long long t=0;
            int co=0;
          a[0][0]=a[0][1]=x;
          a[0][2]=a[0][3]=y;
          for(int i=1;i<6;i++)
          {
              for(int j=0;j<4;j++)
                a[i][j]=a[0][j];
          }
          swap(a[1][0],a[1][2]);
          swap(a[1][1],a[1][3]);
          swap(a[2][1],a[2][2]);
          swap(a[3][1],a[3][3]);
          swap(a[4][0],a[4][2]);
          swap(a[5][0],a[5][3]);
          for(int i=0;i<6;i++)
          {
              for(int q=0;q<3;q++)
              for(int w=0;w<3;w++)
                    for(int e=0;e<3;e++)
                  {  t=a[i][0];
                         if(q==0)
                        t+=a[i][1];
                      else if(q==1)
                       t-=a[i][1];
                      else t*=a[i][1];
                      if(w==0)
                        t+=a[i][2];
                      else if(w==1)
                       t-=a[i][2];
                      else t*=a[i][2];
                      if(e==0)
                        t+=a[i][3];
                      else if(e==1)
                       t-=a[i][3];
                      else t*=a[i][3];
                     if(t==ans)
                       co++;
                   //   cout<<co<<endl;
                  }
    
    
          }
          printf("%d\n",co);
    
        }
    }
    
    
    • 1

    Information

    ID
    19283
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    (None)
    # Submissions
    0
    Accepted
    0
    Uploaded By