poj2586
来源:互联网 发布:传奇数据溢出 编辑:程序博客网 时间:2024/05/22 00:51
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
long long s,d;
while(cin>>s>>d)
{
int a,b;
bool f=1;
for(int i=4;i>=1;i--)
{
if(i*s<d*(5-i))
{
a=i;
b=5-i;
f=0;
break;
}
}
if(f)
{
cout<<"Deficit"<<endl;
continue;
}
long long sum=2*(a*s-b*d);
if(a==1)sum+=s-d;
else sum+=2*s;
if(sum<0)cout<<"Deficit"<<endl;
else cout<<sum<<endl;
}
return 0;
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
long long s,d;
while(cin>>s>>d)
{
int a,b;
bool f=1;
for(int i=4;i>=1;i--)
{
if(i*s<d*(5-i))
{
a=i;
b=5-i;
f=0;
break;
}
}
if(f)
{
cout<<"Deficit"<<endl;
continue;
}
long long sum=2*(a*s-b*d);
if(a==1)sum+=s-d;
else sum+=2*s;
if(sum<0)cout<<"Deficit"<<endl;
else cout<<sum<<endl;
}
return 0;
}
一开始考虑少了一个问题,s>d怎么破。。。然后一直WA
0 0
- poj2586
- poj2586
- poj2586
- poj2586
- poj2586
- poj2586
- poj2586
- POJ2586
- POJ2586
- POJ2586
- poj2586
- poj2586
- poj2586
- poj2586
- POJ2586
- poj2586
- POJ2586
- POJ2586--贪心
- Lowest Common Ancestor of a Binary Search Tree -- leetcode
- Codeforces Beta Round #3-C. Tic-tac-toe
- 黑马程序员——IOS学习笔记(Foundation框架(二))
- 用exp无法导出空表解决方法/用exp导出数据时表丢失原因
- plupload 使用案例 及 中文文档
- poj2586
- Prolog第三天作业
- MySQL的备份与还原
- 自定组合控件的过程
- 栈与递归实现Hanoi塔问题
- MMD_2c_FrequentItemsets
- 一个Java对象到底占用多大内存
- git将本地仓库上传到远程仓库
- python实现smtp发送邮件类-直接调用就好