题目连接

题意:

给 n,a,b,c四个数,n为已有的书的数目,问再买k本书所需花费最少是多少,(k+n)%4==0;

有三种套餐

第一种只有一本书,花费a

第二种有两本书,花费b,

第三种有三本书,花费c.

暴力,n,k只有四种情况:n=0,k=0;   n=1,k=3;    n=2,k=2;    n=3,k=1;

n=0时,不用买;

n=1时,有三种买法可以可能出现最优解:3*a;    a+b;   c;

n=2时,有三种买法可以可能出现最优解: 2*a;  b;   2*c;

n=3时,有三种买法可以可能出现最优解: a; b+c;   3*c;

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#define ll long long
using namespace std;
const ll N=1e9+;
int main()
{
ll n,a,b,c,d,ans;
while(~scanf("%lld%lld%lld%lld",&n,&a,&b,&c))
{
ans=1e12;
n=n%;
//cout<<n<<endl;
if(n==)
{
ans=min(*a,ans);
ans=min(a+b,ans);
ans=min(c,ans);
}
else if(n==)
{
ans=min(*a,ans);
ans=min(b,ans);
ans=min(*c,ans);
}
else if(n==)
{
ans=min(a,ans);
ans=min(b+c,ans);
ans=min(*c,ans);
}
else
ans=;
printf("%lld\n",ans);
}
return ;
}

Alyona and copybooks的更多相关文章

  1. Codeforces Round #381 (Div. 2)A. Alyona and copybooks(dfs)

    A. Alyona and copybooks Problem Description: Little girl Alyona is in a shop to buy some copybooks f ...

  2. Codeforces 740A. Alyona and copybooks 模拟

    A. Alyona and copybooks time limit per test: 1 second memory limit per test: 256 megabytes input: st ...

  3. 【20.23%】【codeforces 740A】Alyona and copybooks

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. A.Alyona and copybooks

    这题考查思维的全面性. 一开始我直接分类推公式,余数不同分类讨论. AC代码: #include<cstdio> #include<algorithm> using names ...

  5. CodeForces 740A Alyona and copybooks

    完全背包. 直接做个背包容量为$100000$的完全背包,这样就可以避免繁琐的分类讨论了. #pragma comment(linker, "/STACK:1024000000,102400 ...

  6. Codeforces Round #381 (Div. 2) A B C 水 构造

    A. Alyona and copybooks time limit per test 1 second memory limit per test 256 megabytes input stand ...

  7. Codeforces Round #381 (Div. 2) 复习倍增//

    刷了这套题  感触良多 我想 感觉上的差一点就是差很多吧 . 每次都差一点  就是差很多了... 不能气馁..要更加努力去填补那一点点.  老天不是在造物弄人,而是希望你用更好的自己去迎接自己. A. ...

  8. CODEFORCES ROUND #740 ANALYSES BY TEAM:RED & BLACK

    A.Alyona and copybooks Problems: 给你一个数n和代价分别为a, b, c.数量不限的1, 2, 3,求将n凑成4的倍数的最小代价 Analysis: cj:取个模随便凑 ...

  9. Codeforces Round #381 (Div. 2)D. Alyona and a tree(树+二分+dfs)

    D. Alyona and a tree Problem Description: Alyona has a tree with n vertices. The root of the tree is ...

随机推荐

  1. Oracle 补丁及opatch 工具介绍

    一. CPU(Critical Patch Update) 一个CPU内包含了对多个安全漏洞的修复,并且也包括相应必需的非安全漏洞的补丁.CPU是累积型的,只要安装最新发布的CPU即可,其中包括之前发 ...

  2. sublime text 3 插件:package control

    sublime text 3安装package control import urllib.request,os,hashlib; h = 'eb2297e1a458f27d836c04bb0cbaf ...

  3. div光标定位问题总结

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. IOS研究院之打开照相机与本地相册选择图片(六)

    原创文章如需转载请注明:转载自雨松MOMO程序研究院本文链接地址:IOS研究院之打开照相机与本地相册选择图片(六) Hello 大家好 IOS的文章好久都木有更新了,今天更新一篇哈. 这篇文章主要学习 ...

  5. SQL Server中日志

    再谈SQL Server中日志的的作用 简介 之前我已经写了一个关于SQL Server日志的简单系列文章.本篇文章会进一步挖掘日志背后的一些概念,原理以及作用.如果您没有看过我之前的文章,请参阅: ...

  6. jQuery Validation让验证变得如此容易(二)

    上一个例子我们是统一引用jquery.validate.js这样所有必填字段的提示信息都将是This field is required. 现在要改成动态提示,比如姓名如果为空则提示姓名不能为空,密码 ...

  7. Microsoft 2013校园招聘笔试题及解答

    Microsoft 2013校园招聘笔试题及解答 题目是自己做的,求讨论.吐槽.拍砖 1.      Which of the following callingconvension(s) suppo ...

  8. Microsoft2013校园招聘笔试题

    Microsoft2013校园招聘笔试题 继续求拍砖!!!! 1. You are managing the database of a book publichser, you currently ...

  9. TOGAF架构内容框架之架构制品(上)

    TOGAF架构内容框架之架构制品(上) 4. 架构制品(Architectural Artifacts) 架构制品是针对某个系统或解决方案的模型描述,与架构交付物和构建块相比,架构制品既不是架构开发方 ...

  10. Yellow

    Yellow这首歌让我知道了yellow这个单词出了黄色的意思外,还有胆怯的,懦弱的意思~~~ 它是Coldplay 的歌曲,歌词很简单,但是有着莫名的忧伤感,值得一提的是这首歌的MV,一个长镜头给出 ...