7 条题解

  • 5
    @ 2022-12-10 15:37:35

    AC代码,放心使用

    #include <iostream>
    using namespace std;
    int main()
    {
        int a, b, c, d;
        int n, m;
        cin >> n >> m;
        for (c = 0; c <= n; c += 3)
        {
            d = c / 3;
            for (b = 0; b <= n; b += 1)
            {
                for (a = 0; a <= n; a += 1)
                {
                    if ((a + b + c == m) && (5 * a + 3 * b + d == n))
                    {
                       cout << a << " " << b << " " << c << endl;   
                    }
                }
            }
        }
        return 0;
    }
    
    • 2
      @ 2023-11-7 18:46:00
      #include <bits/stdc++.h>
      using namespace std;
      int main()
      {
          ios::sync_with_stdio(false);
          cin.tie(nullptr);
          int n, m;
          cin >> n >> m;
          for (int i = 0; i <= m; i++)
          {
              for (int j = 0; j <= m; j++)
              {
                  int k = m - i - j;
                  if (i * 5 + j * 3 + k / 3 * 1 == n && k % 3 == 0)
                      cout << i << " " << j << " " << k << endl;
              }
          }
          return 0;
      }//以AC
      
      • 1
        @ 2023-7-7 21:24:41
        #include <iostream>
        using namespace std;
        int main()
        {
        	int n, m;
        	cin >> n >> m;
        	for (int i = 0; i <= n / 5 + 1; i++)
        	{
        		for (int j = 0; j <= n / 3 + 1; j++)
        		{
        			if (14 * i + 8 * j == 3 * n - m)
        			{
        				cout << i << " " << j << " " << m - i - j << endl;
        			}
        		}
        	}
        	return 0;
        }
        
        • 0
          @ 2024-5-8 21:43:50
          #include <bits/stdc++.h>
          using namespace std;
          int n,m;
          int main(){
          	cin>>n>>m;
          	for (int i=0;i<=ceil(n/5);i++){
          		for (int j=0;j<=ceil(n/3);j++){
          			int k=n-i*5-j*3;
          			if (k*3+i+j==m)cout<<i<<" "<<j<<" "<<k*3<<endl;
          		}
          	}
          	return 0;
          }
          
          • 0
            @ 2023-10-4 23:59:44
            #include<bits/stdc++.h>
            using namespace std;
            int n,m;
            int main()
            {
                cin>>n>>m;
                for(int i=0;i<=n/5;i++)
                {
                    for(int j=0;j<=n/3;j++)
                    {
                        for(int k=0;k<=n*3;k++)
                        {
                            if(i*5+j*3+k/3==n&&i+j+k==m&&k%3==0)
                            {
                                cout<<i<<" "<<j<<" "<<k<<endl;
                            }
                        }
                    }
                }
                return 0;
            }
            
            • 0
              @ 2023-7-29 22:52:21
              #include <bits/stdc++.h>
              using namespace std;
              int n,m;
              int main()
              {
                  cin>>n>>m;
                  for(int i=0;i<=n;i++)
                  {
                      for(int j=0;j<=n;j++)
                      {
                          int k=(n-5*i-3*j)*3;
                          if(i+j+k==m)
                              cout<<i<<" "<<j<<" "<<k<<endl;
                      }
                  }
                  return 0;
              }
              
              • 0
                @ 2023-1-17 17:02:18
                #include<bits/stdc++.h>
                using namespace std;
                int main()
                {
                    int a, b, c;
                    int n, m;
                    cin >> n >> m;
                    for (a = 0; a <= n/5; a += 1)
                    {
                        for (b = 0; b <= n/3; b += 1)
                        {
                            c = (n - 5*a - 3*b)*3;
                			        
                                if (a + b + c == m && c % 3 == 0)
                                {
                                   cout << a << " " << b << " " << c << endl;   
                                }
                            
                        }
                    }
                    return 0;
                }
                不超时
                
                • 1

                信息

                ID
                78
                时间
                1000ms
                内存
                16MiB
                难度
                4
                标签
                递交数
                162
                已通过
                74
                上传者