题目连接

题意:

给 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. springmvc3.1.1+hibernate4

    上篇介绍了基本的配置,这篇着重介绍与hibernate4整合. 1.web.xml文件中加入spring-hibernate的配置.新的web.xml文件内容如下: <?xml version= ...

  2. 在线预览PDF

    FlexPaper+SWFTool+操作类=在线预览PDF   引言 由于客户有在线预览PDF格式的需求,在网上找了一下解决方案,觉得FlexPaper用起来还是挺方便的,flexpaper是将pdf ...

  3. 一种最坏情况线性运行时间的选择算法 - The missing worst-case linear-time Select algorithm in CLRS.

    一种最坏情况线性运行时间的选择算法 - The missing worst-case linear-time Select algorithm in CLRS. 选择算法也就是求一个无序数组中第K大( ...

  4. struts整合spring整合hibernate

    1, web.xml中配置spring监听类 <listener> <listener-class>org.springframework.web.context.Contex ...

  5. 两种高性能 I/O 设计模式 Reactor 和 Proactor

    两种高性能 I/O 设计模式 Reactor 和 Proactor Reactor 和 Proactor 是基于事件驱动,在网络编程中经常用到两种设计模式. 曾经在一个项目中用到了网络库 libeve ...

  6. Ubuntu apt-get: Package has no installation candidate

    今天在安装软件的时候出现了Package has no installation candidate的问题,如: #  apt-get install <packagename>Readi ...

  7. 昨天CSAPP上的疑问的解答

    昨天CSAPP上的疑问的解答 今天整明白了. CSAPP英文版第2版,826页,或者中文版第2版546页,有这么一段.关于多级页表的. "But if we had a 32-bit add ...

  8. android自定义View---生成虚线的View

    1.在res/values/目录下 新建文件 attrs.xml <?  xml   version =  "1.0"   encoding =  "utf-8&q ...

  9. j2ee面试宝典翻译(1)

    q1:给出一些使用Java的理由? a1:java是一个有趣的编程语言,让我找出一些理由来: 内建的多线程机制.套接字.内存管理(自动垃圾回收) 面向对象 跨平台 通过对标准API的扩展来支持基于we ...

  10. https时代来了,你却还一无所知?

    本文作者:茄果,专注前端开发领域,更多文章请关注知乎专栏<前端小事> 现在打开各大知名网站,你有没有发现地址栏都已经加了个绿色的小锁? 是的,这就是https,这就是https的时代. 然 ...