2 条题解

  • 0
    @ 2023-3-17 20:43:28
    #include<bits/stdc++.h>
    using namespace std;
    //输入保证正确
    //输出看仔细
    //所有情况都测
    //数组定义,保证正确
    
    int main()
    {
    	int x , y;
    	cin >> x >>y;
    	double h=0,f=0;
    	if(x<=2760)
    	{
    		if(y<=2760)
    			h=y-x;
    		else
    			h=2760-x;
    		f=1;
    	}
    	else if(x>=2760&&x<=4800)
    	{
    		if(y<=4800)
    			h=y-x;
    		else
    			h=4800-x;
    		f=2;
    	}
    	else
    		f=3;
    	double sum = 0;
    	y=y-x;
    	int t=1;
    //	cout<<x<<" ";
    	while(y>0)
    	{
    //		cout<<fixed << setprecision(2)<<sum<<" ";
    		if(t==1)
    		{
    			if(f==1)
    			{
    				sum=sum+h*0.52;
    			}
    			if(f==2)
    			{
    				sum=sum+h*0.57;
    			}
    			if(f==3)
    			{
    				sum=sum+y*0.82;
    				y=0;
    			}
    			y-=h;
    		}
    		else
    		{
    			if(f==2)
    			{
    				if(y>=2040)
    				{
    					y-=2040;
    					sum=sum+2040*0.57;
    				}
    				else
    				{
    					sum=sum+y*0.57;
    					y=0;
    				}
    			}
    			else
    			{
    				sum=sum+y*0.82;
    				y=0;
    			}	
    		}
    		f++;
    		t++;
    	}
    	cout<<fixed << setprecision(2)<<sum<<endl;
     	return 0;
    }
    
    

    信息

    ID
    450
    时间
    1000ms
    内存
    256MiB
    难度
    1
    标签
    递交数
    86
    已通过
    44
    上传者