The 15th UESTC Programming Contest Preliminary C - C0ins cdoj1554
地址:http://acm.uestc.edu.cn/#/problem/show/1554
题目:
C0ins
Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)
There are infinite coins with values 1,2,5,101,2,5,10.
What's the minimum numbers of coins should be picked that XX and YY can be made change for?
Input
Two integers XX and YY. (1≤X,Y≤1091≤X,Y≤109)
Output
The minimum numbers of coins should be picked.
Sample input and output
Sample Input | Sample Output |
---|---|
8 9 |
4 |
Hint
In sample, four coins 1,2,2,51,2,2,5 and 1,1,2,51,1,2,5 both can make change for 88 and 99.
Source
#include<iostream>
#include<algorithm>
using namespace std; long long a,b,aa,bb,ans1,ans2,ans110,ans15,ans12,ans11,ans210,ans25,ans22,ans21; int check(int a,int b)
{
long long aa,bb,ans1,ans2,ans110,ans15,ans12,ans11,ans210,ans25,ans22,ans21;
aa=bb=ans1=ans2=ans110=ans15=ans12=ans11=ans210=ans25=ans22=ans21=;
aa=a,bb=b;
if(a<||b<)
return ;
ans110+=a/;
a%=;
ans15+=a/;
a%=;
ans12+=a/;
a%=;
ans11+=a;
ans210+=b/;
b%=;
ans25+=b/;
b%=;
ans22+=b/;
b%=;
ans21+=b;
ans1=max(ans110,ans210)+max(ans15,ans25)+max(ans12,ans22)+max(ans11,ans21);
ans2=ans110+ans15+ans11+ans12;
bb-=aa;
ans2+=bb/;
bb%=;
ans2+=bb/;
bb%=;
ans2+=bb/;
bb%=;
ans2+=bb;
return min(ans2,ans1);
} int main()
{
cin>>a>>b;
if(a>b)
swap(a,b);
cout<<min(check(a,b),check(a-,b-)+);
return ;
}
The 15th UESTC Programming Contest Preliminary C - C0ins cdoj1554的更多相关文章
- The 15th UESTC Programming Contest Preliminary J - Jermutat1on cdoj1567
地址:http://acm.uestc.edu.cn/#/problem/show/1567 题目: Jermutat1on Time Limit: 3000/1000MS (Java/Others) ...
- The 15th UESTC Programming Contest Preliminary B - B0n0 Path cdoj1559
地址:http://acm.uestc.edu.cn/#/problem/show/1559 题目: B0n0 Path Time Limit: 1500/500MS (Java/Others) ...
- The 15th UESTC Programming Contest Preliminary K - Kidd1ng Me? cdoj1565
地址:http://acm.uestc.edu.cn/#/problem/show/1565 题目: Kidd1ng Me? Time Limit: 3000/1000MS (Java/Others) ...
- The 15th UESTC Programming Contest Preliminary M - Minimum C0st cdoj1557
地址:http://acm.uestc.edu.cn/#/problem/show/1557 题目: Minimum C0st Time Limit: 3000/1000MS (Java/Others ...
- The 15th UESTC Programming Contest Preliminary G - GC?(X,Y) cdoj1564
地址:http://acm.uestc.edu.cn/#/problem/show/1564 题目: G - GC?(X,Y) Time Limit: 3000/1000MS (Java/Others ...
- The 15th UESTC Programming Contest Preliminary H - Hesty Str1ng cdoj1551
地址:http://acm.uestc.edu.cn/#/problem/show/1551 题目: Hesty Str1ng Time Limit: 3000/1000MS (Java/Others ...
- The 15th UESTC Programming Contest Preliminary D - Destr0y City cdoj1558
地址:http://acm.uestc.edu.cn/#/problem/show/1558 题目: D - Destr0y City Time Limit: 3000/1000MS (Java/Ot ...
- 【set】【可持久化Trie】The 16th UESTC Programming Contest Preliminary K - Will the circle be broken
题意:You are given an array A of N non-negative integers and an integer M. Find the number of pair(i,j ...
- 【字符串哈希】The 16th UESTC Programming Contest Preliminary F - Zero One Problem
题意:给你一个零一矩阵,q次询问,每次给你两个长宽相同的子矩阵,问你它们是恰好有一位不同,还是完全相同,还是有多于一位不同. 对每行分别哈希,先一行一行地尝试匹配,如果恰好发现有一行无法对应,再对那一 ...
随机推荐
- Loadrunner如何遍历一个页面中的url并进行访问?
最近在网上到一个关于loadrunner遍历一个页面中的url并进行访问的脚本,就把它用我们自己的项目实践了一下,发现有一点不完善. 原始版本: Action(){char temp[64];int ...
- Myeclipse 10 Maven 构建 Java Web 项目
主要介绍如何使用 Myeclipse 10 构建 Maven Web 项目,关于 Maven 的介绍就略过了. 工具/原料 myeclipse apache-maven-3.1.0 方法/步骤 1 下 ...
- Matplotlib植入PyQt5 + QT5的UI呈现
实现matplotlib图形通过PyQt5+Qt5在GUI中呈现步骤: 第一步,通过matplotlib.backends.backend_qt5agg类来连接PyQt5: import matplo ...
- UE4插件
源代码中包含一些插件例子 C:\Program Files\Epic Games\UE_4.15\Engine\Plugins\Developer 一下截图来自官网https://docs.unrea ...
- Django -- some config
1.主项目下的url配置:urls.py文件 from django.contrib import adminfrom django.urls import path, includefrom dja ...
- Code Forces 645C Enduring Exodus
C. Enduring Exodus time limit per test2 seconds memory limit per test256 megabytes inputstandard inp ...
- netty 网关 http请求 请求转发
https://netty.io/4.1/xref/io/netty/example/proxy/package-summary.html https://netty.io/4.1/xref/io/n ...
- 神、上帝以及老天爷--hdu2048(错排,递推)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2048 1. N张字条的所有可能排列自然是N!(分母). 现在的问题就是求N张字条的错排数f(N)(分子 ...
- 日期Date 对象常用的方法
var mydate = new Date();//通过new方法创建对象 //alert(Date()); // 返回一个完整的日期时间 // alert(mydate.getDay());//返回 ...
- 前端 javascript 数据类型 数字
1.数字(Number) JavaScript中不区分整数值和浮点数值,JavaScript中所有数字均用浮点数值表示. 转换: parseInt(..) 将某值转换成数字,不成功则NaN pa ...