当前位置:编程学习 > C/C++ >>

poj2586

#include<stdio.h>   
int main()  
{  
      int s, d, re;  
      while(scanf("%d%d",&s, &d)!=EOF)  
      {  
          if(4*s-d<0)  
              re=10*s-2*d;  
          else if(3*s-2*d<0)  
              re=8*s-4*d;  
          else if(2*s-3*d<0)  
              re=6*s-6*d;  
          else if(s-4*d<0)  
              re=3*s-9*d;  
          else   
              re=-1;  
          if(re<0)  
              printf("Deficit\n");  
          else  
              printf("%d\n", re);  
      }  
}  

#include<stdio.h>
int main()
{
      int s, d, re;
      while(scanf("%d%d",&s, &d)!=EOF)
      {
          if(4*s-d<0)
              re=10*s-2*d;
          else if(3*s-2*d<0)
              re=8*s-4*d;
          else if(2*s-3*d<0)
              re=6*s-6*d;
          else if(s-4*d<0)
              re=3*s-9*d;
          else 
              re=-1;
          if(re<0)
              printf("Deficit\n");
          else
              printf("%d\n", re);
      }
}


 

补充:软件开发 , C++ ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,