1 solutions

  • 0
    @ 2025-3-3 16:24:10

    C :

    #include<stdio.h>
    
    int main()
    {
    	int t,n,m,c1,c2,c5,k;
    	scanf("%d",&t);
    	while(t--)
    	{
    		scanf("%d%d",&n,&m);
    		k=0;
    		for(c5=0;5*c5<=m;c5++)
    			for(c2=0;2*c2+5*c5<=m;c2++)
    			{
    				c1=m-5*c5-2*c2;
    				if(c1+c2+c5==n)
    					k++;
    			}
    		printf("%d\n",k);
    	}
    	return 0;
    }
    

    C++ :

    #include<stdio.h>
    
    int main()
    {
    	int t,n,m,c1,c2,c5,k;
    	scanf("%d",&t);
    	while(t--)
    	{
    		scanf("%d%d",&n,&m);
    		k=0;
    		for(c5=0;5*c5<=m;c5++)
    			for(c2=0;2*c2+5*c5<=m;c2++)
    			{
    				c1=m-5*c5-2*c2;
    				if(c1+c2+c5==n)
    					k++;
    			}
    		printf("%d\n",k);
    	}
    	return 0;
    }
    
    • 1

    Information

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