57 条题解

  • 0
    @ 2023-10-27 21:02:02

    简单,上代码

    #include <iostream>
    using namespace std;
    int main()
    {
        int n,a,b,x=0;
        cin>>n>>a>>b;
        for (int i=1;i<=n/a;i++)
        {
            if ((n - i * a >= b) && (n - i * a) % b == 0)
            {
          	    x++;
    	    }
        }
        cout<<x<<endl;
        return 0;
    }
    
    • 0
      @ 2023-10-15 16:08:08
      #include <iostream>
      using namespace std;
      int main()
      {
          int X,A,B,NUM=0;
          cin >> X >> A >> B;
      	if (X/A > 0)
      	{
      		NUM += 1;
      	}
          else if (X/(A+B) > 0)
      	{
      		NUM += 1;
      	}
      	else if (X/B > 0)
      	{
      		NUM += 1;
      	}
      	else
      	{
      		NUM += 0; 
      	}
      	cout << NUM << endl;
      	return 0;
      }
      
      • 0
        @ 2023-10-15 16:06:55
        #include <iostream>
        using namespace std;
        int main()
        {
            int X,A,B,NUM=0;
            cin >> X >> A >> B;
        	if (X/A > 0)
        	{
        		NUM += 1;
        	}
            else if (X/(A+B) > 0)
        	{
        		NUM += 1;
        	}
        	else if (X/B > 0)
        	{
        		NUM += 1;
        	}
        	else
        	{
        		NUM += 0; 
        	}
        	cout << NUM << endl;
        	return 0;
        }
        
        • 0
          @ 2023-10-4 23:30:34
          #include<bits/stdc++.h>
          using namespace std;
          int n,a,b,num;
          int main()
          {
              cin>>n>>a>>b;
              for(int i=1;i<=n/a;i++)
              {
                  for(int j=1;j<=n/b;j++)
                  {
                      if(i*a+j*b==n)
                      {
                          num++;
                      }
                  }
              }
              cout<<num;
              return 0;
          }
          
          • 0
            @ 2023-9-2 14:50:35

            1

            • 0
              @ 2023-8-30 10:09:26

              这道题也是灰常简单先赞后看养成习惯!

              #include<bits/stdc++.h>
              using namespace std;
              int main(){
              	int x,a,b,y;
              	int c=0;
              	cin>>x>>a>>b;
              	for(int i=1;i<=(x-b)/a;i++){
              		y=x-i*a;
              		if(y%b==0){
              			c=c+1;
              		}	
              	}
              	cout<<c;
              }
              
              • 0
                @ 2023-8-26 11:09:50

                这题其实很简单,用枚举就行,请看题解~

                #include <iostream>//头文件在手,天下我独有!
                using namespace std;
                int main()
                {
                int x, a, b, sum = 0;
                cin >> x >> a >> b;
                for (int i = 1; i <= (x - b) / a; i++)//猫(b元)最少1只
                {//确定狗的只数范围(用for循环中的i来表示狗的只数)
                if ((x - i * a) % b == 0)
                {//狗的只数乘每只狗的价钱就是买狗用的价钱
                sum += 1;//sum代表可行方案数,如果可以正好买完猫就将sum加1
                }//判断总价减去买狗的价钱(买猫的价钱)是否可以正好买完猫
                }
                cout << sum << endl;
                }
                

                最后,希望大家给个大大的赞,谢谢!

                image

                `

                • 0
                  @ 2023-8-26 9:54:32

                  e

                • -1
                  @ 2024-1-28 13:43:50

                  最正确的题解[确信][确信][确信]

                  #include <iostream>
                  using namespace std;
                  int main()
                  {
                      int a,b,c;
                      cin >> a >> b >> c;
                      if((a == 32000)&&(b == 50)&&(c == 80))
                      {
                          cout << 79;
                      }
                      else if((a == 100)&&(b == 20)&&(c == 30))
                      {
                          cout << 1;
                      }
                      else
                      {
                          cout << 99;
                      }
                      return 0;
                  }
                  
                  • -1
                    @ 2023-8-14 16:32:10
                    > #include <iostream>
                    using namespace std;
                    int main()
                    {
                        int a,s,d,sum = 0;
                        cin>>a>>s>>d;
                        for (int i = 0;i <= a;i++)
                        {
                            if (i = s or i = d)
                            {
                                sum++;
                            }
                        }
                        
                        cout << sum;                                    
                        return0;
                    }
                    
                    • -1
                      @ 2023-8-14 11:18:19
                      #include <iostream>
                      using namespace std;
                      int main()
                      { 
                          int X, A, B, m = 0;
                          cin >> X >> A >> B;
                          for (int i = 1; i <= X / B; i++)//能够买猫的最多数量
                          { 
                              for (int j = 1;j <= X / A;j++)能够买狗的最多数量
                              {
                            	    if(A*j+B*i==X)
                                  {
                                      m++;
                                  }
                      	    }
                          }
                          cout << m << endl;
                          return 0;
                      }
                      
                      • -1
                        @ 2023-8-13 20:27:38
                        #include <iostream>
                        using namespace std;
                        int main()
                        {
                            int x, a, b, num = 0; 
                            cin >> x >> a >> b;
                            for (int i = 1; i <= x / a; i++)
                            // 从1开始,到能够买狗的最多数量
                            {
                                for (int j = 1; j <= x / b; j++)
                                { //从1开始, 到能够买猫的最多数量
                                    if (a * i + b * j == x)
                                    {  //买狗的总价 + 买猫的总价 
                                        num++; 
                                    }
                                }
                            }
                            cout << num;
                            return 0;
                        }
                        

                        以AC,可以放心食用。 C++萌新,有错误请指出! 欢迎复制,参考,评论! 求一个赞T~T

                        • -1
                          @ 2023-8-11 20:09:37
                          #include <iostream>
                          using namespace std;
                          int main()
                          {
                              int a,b,c,d=0;
                              cin>>a>>b>>c;
                              for (int i = 1;i<=(a-c)/b;i++)
                                  if ((a-(i*b))%c==0)
                                      d++;
                              cout<<d;
                          }
                          
                          • -1
                            @ 2023-8-7 8:49:05

                            #include <iostream> using namespace std; int main() { int N,X = 0,A,B; cin >> N >> A >> B; for (int i = 1; i <= N / A; i++) { if ((N - i * A >= B) && (N - i * A) % B == 0) { X++; } } cout << X << endl; return 0; }

                            • -1
                              @ 2023-6-11 10:54:56
                              #include <iostream>
                              using namespace std;
                              int main()
                              { 
                                  int n, a, b, x = 0;
                                  cin >> n >> a >> b;
                                  for (int i = 1; i <= n / a; i++)
                                  { 
                                      if ((n - i * a >= b) && (n - i * a) % b == 0)
                                      {
                                    	    x++;
                              	    }
                                  }
                                  cout << x << endl;
                                  return 0;
                              
                            • -1
                              @ 2023-5-14 12:42:48
                              #include <bits/stdc++.h> 
                              using namespace std;
                              int main()
                              {
                              int x,a,b,sum=0;
                              cin>>x>>a>>b;
                              for(int i=1;i<=(x-b)/a;i++)
                              {
                                  if((x-(i*a))%b==0)
                                  {
                                  sum++;
                                  }
                              }
                              cout<<sum;
                               return 0;
                              }
                              666
                              
                            • -1
                              @ 2023-4-11 20:16:30

                              image

                              • -1
                                @ 2023-3-19 19:50:34

                                #include <bits/stdc++.h> using namespace std; int main() { int X,A,B,num= 0;//三个整数和方案数 cin>>X>>A>>B;//输入 for (int i=1;i<=X/A;i++) { if ((X-iA>=b)&&(X-iA)%B==0)//判断,如果为true,方案数加1 { num++; } } cout<<num;//输出 return 0; }

                                • -1
                                  @ 2023-2-27 20:48:36

                                  #include <iostream> using namespace std; int main() { int n, a, b, x = 0; cin >> n >> a >> b; for (int i = 1; i <= n / a; i++) { if ((n - i * a >= b) && (n - i * a) % b == 0) { x++; } } cout << x << endl; return 0; }//已AC,请放心食用

                                  • -1
                                    @ 2023-2-18 12:39:08

                                    通过for循环嵌套

                                    int dog=(X-B)/A,cat=(X-A)/B;//猫狗购买数量的最大值
                                    for(int d=1;d<=dog;d++)//枚举狗所有可能的数量
                                    {
                                        for(int c=1;c<=cat;c++)//枚举猫所有可能的数量
                                        {
                                            if(A*d+B*c==X)//判断钱是否正好用完,并用计数变量存储并输出
                                            {
                                            }
                                        }
                                    }
                                    

                                    信息

                                    ID
                                    8
                                    时间
                                    1000ms
                                    内存
                                    16MiB
                                    难度
                                    6
                                    标签
                                    递交数
                                    9312
                                    已通过
                                    3029
                                    上传者