5 条题解

  • 5
    @ 2023-7-29 22:39:11

    简单的嵌套循环

    AC代码:

    #include <bits/stdc++.h>
    using namespace std;
    int ans;
    int main()
    {
        for(int i=1;i<=12;i++)
        {
            for(int j=1;j<=50;j++)
            {
                for(int k=1;k<=34;k++)
                {
                    if(9*i+j+k==100&&i*2+j*2+k*4==100)
                    {
                        cout<<i<<" "<<j<<" "<<k<<endl;
                        ans++;
                    }
                }
            }
        }
        cout<<ans;
        return 0;
    }
    
    • @ 2023-7-29 22:40:21

      也可以直接输出

      7 31 6
      8 14 14
      2
      
  • 3
    @ 2022-12-10 15:32:00
    #include <iostream>
    #include <stdio.h>
    using namespace std;
    int main()
    {
        int x,y,z,i=0;
        for(x=0;x<=11;x += 1)
        {
            for(y=0;y<=50;y += 1)
            {
                for(z=0;z<=25;z += 1)
                {
                    if((9*x+y+z==100) && (x+y+2*z==50))
                    {
                        printf("%d %d %d\n",x,y,z);
                        i += 1;
                    }
                }
            }
        }
        cout << i;
        return 0;
    }//已AC
    

    输出:

    7 31 6

    8 14 14

    2

    • 2
      @ 2023-10-4 23:46:51
      #include<bits/stdc++.h>
      using namespace std;
      int num;
      int main()
      {
          for(int i=1;i<=11;i++)
          {
              for(int j=1;j<=80;j++)
              {
                  for(int k=1;k<=40;k++)
                  {
                      if(i*2+j*2+k*4==100&&i*9+j+k==100)
                      {
                          cout<<i<<" "<<j<<" "<<k<<endl;
                          num++;
                      }
                  }
              }
          }
          cout<<num;
          return 0;
      }
      
      • 2
        @ 2023-7-7 21:23:30

        #include <iostream> #include <cmath> using namespace std; int main() { int num = 0; for (int i = 0; i <= 11; i++)//鸟 { for (int j = 0; j <= 50; j++)//只因 { for (int k = 0; k <= 25; k++)//兔 { if (9 * i + j + k == 100 && 2 * i + 2 * j + 4 * k == 100) { cout << i << " " << j << " " << k << endl; num++; } } } } cout << num; return 0; }

        • 0
          @ 2024-5-8 21:37:49
          #include <bits/stdc++.h>
          using namespace std;
          int ans;
          int main(){
          	for (int i=1;i<=15;i++){
          		for (int j=1;j<=50;j++){
          			for (int k=1;k<=25;k++){
          				if (i*9+j+k==100&&i*2+j*2+k*4==100){
          					cout<<i<<" "<<j<<" "<<k<<endl;
          					ans++;
          				}
          			}
          		}
          	}
          	cout<<ans;
          	return 0;
          }
          
          • 1

          信息

          ID
          77
          时间
          1000ms
          内存
          16MiB
          难度
          3
          标签
          递交数
          173
          已通过
          89
          上传者