1 solutions

  • 0
    @ 2025-3-3 16:33:14

    C :

    #include<stdio.h>
    int main()
    {
        int a,b,c,i,s=0;
        scanf("%d%d%d",&a,&b,&c);
        if(a%b==0)
        {
            for(i=1;i<=a/b-1;i++)
            {
                   if(((a-b*i)%c==0)&&((a-b*i)>=c))
                   {
                       if((a-b*i)/c>=10&&i>=10)
                           s++;
                   }
            }
            printf("%d",s);
        }
        
        if(a%b!=0)
        {
            for(i=1;i<=a/b;i++)
            {
                if((a-b*i)/c>=10&&i>=10)
                    s++;
            }
            printf("%d",s);
        }
       
        return 0;
    }
    
    

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
    	int i,n,x,y,t,c = 0;
    	cin>>n>>x>>y;
    	for(i = 10;i <= (n - y) / x;i++){
    		t = n - i * x;
    		if(t % y == 0 && t / y >= 10){
    			c++;
    //			cout<<i<<" "<<t / y<<endl;
    		}
    	}
    	
    	cout<<c;
    }
    
    
    

    Java :

    import java.util.Scanner;
    public class Main {
    
    	public static void main(String[] args) {
    		Scanner input = new Scanner(System.in);
    		int n = input.nextInt();
    		int x = input.nextInt();
    		int y = input.nextInt();
    		int count = 0;
    		for(int i = 10;i <= n - 10 * y / x;i++) {
    			for(int j = 10;j <= n - 10 * x / y;j++) {
    				if(i * x + j * y == n ) {
    					count++;
    				}
    			}
    		}
    		System.out.println(count);
    		}
    	}
    

    Python :

    c = 0
    s = input().split()
    n = int(s[0])
    x = int(s[1])
    y = int(s[2])
    for i in range(1, n // x + 1):
        j = (n - i * x) // y
        if x * i + y * j == n and i >= 10 and j >= 10:
            c += 1
    print(c)
    
    
    • 1

    Information

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