1 条题解

  • 0
    @ 2024-12-22 11:04:02

    C :

    #include <stdio.h>
    #include <math.h>
    #include <stdlib.h>
    #include <time.h>
    int main()
    {
      //  freopen("in","r",stdin);
     //   freopen("out","w",stdout);
    
    
       int c,t;
       int m;
        while(scanf("%d%d",&c,&t)!=EOF)
        {
    
    
    
    if (c==t)
    {
    if (c>=50)
    m=c*450;
    else
    m=c*500;
    }
    else
    {
    if (c>t)
    {
    if (t>=50)
    m=t*450+(c-t)*250;
    else
     m=t*500+(c-t)*250;
    }
    else
     {
    if (c>50)
    m=c*450+(t-c)*300;
    else
    m=c*500+(t-c)*300;
    
    }
    }
    printf("%d\n",m);
    
    
    
    
        }
      return 0;
    }
    
    

    C++ :

    #include <stdio.h>
    main()
    {
    	int i,j,price;
    	while (scanf("%d %d",&i,&j)!=EOF)
    	{	if (i==j)
    		{
    			if (i>=50)
    			price=450*i;
    			else
    			price=500*i;
    		}	
    		else
    		{
    			if (i>j)
    			{
    				if (j>=50)
    					price=450*j+250*(i-j);
    				else	
    					price=500*j+250*(i-j);
    			}
    			if (i<j)
    			{
    				if (i>=50)
    					price=450*i+300*(j-i);
    				else
    					price=500*i+300*(j-i);
    			}
    		}
    		printf("%d\n",price);
    
    	}
    
    }
    
    • 1

    信息

    ID
    268
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者