当前位置:网站首页>Informatics Olympiad all in one 2059: [example 3.11] buy a pen
Informatics Olympiad all in one 2059: [example 3.11] buy a pen
2022-06-12 13:23:00 【Xiao Liu wants to be number one】
2059:【 example 3.11】 Buy a pen
The time limit : 1000 ms Memory limit : 65536 KB
Submission number : 15417 Passing number : 8034
【 Title Description 】
The end of the term is coming , Squad leader Q It was decided that the rest of the class fee would be xx Yuan , It is used to buy several pens and reward some good learners 、 Good students . It is known that there are three kinds of pens in the store , Their unit price is 6 element 、5 Genna 4 element . Small Q Want to buy as many pens as possible ( Encourage as many students as possible ), At the same time, he doesn't want to have any surplus money . Please make a program , Help small Q Work out a plan for buying pens .
【 Input 】
A positive integer xx( The rest of the class fee ).
【 Output 】
a line , In turn 6 element 、5 Genna 4 The number of yuan , Separated by a space .
【 sample input 】
10【 sample output 】
1 0 1If you want to buy the most pens, you must buy the cheapest ones (4 element ), The set-up fee is x element , If x/4=0, That is, buy all 4 Yuan pen , if x/4=1, You can buy one less 4 Yuan to buy a pen 5 yuan , if x/4=2, Buy one less 4 Yuan's pen , Buy one 6 Yuan's pen , Empathy , if x/4=3, Buy less 2 only 4 Replace the yuan pen with one 5 A yuan pen 6 Yuan pen .
#include<iostream>
using namespace std;
int main()
{
int x,a,b,c;
cin >> x;
if (x % 4 == 0)
{
a = 0;
b = 0;
c = x / 4;
}
else if (x % 4 == 1)
{
a = 0;
b = 1;
c = x / 4 - 1;
}
else if (x % 4 == 2)
{
a = 1;
b = 0;
c = x / 4 - 1;
}
else if (x % 4 == 3)
{
a = 1;
b = 1;
c = x / 4 - 2;
}
cout << a << " " << b << " " << c;
}边栏推荐
- 苹果电脑上MySQL安装完成找不到怎么办
- 442个作者100页论文!谷歌耗时2年发布大模型新基准BIG-Bench | 开源
- verilog-mode的简要介绍
- Script import CDN link prompt net:: err_ FILE_ NOT_ Found problem
- Actual combat | realizing monocular camera ranging by skillfully using pose solution
- R语言ggplot2可视化:使用ggrepel包在线图(line plot)的尾端那个数据点添加数值标签(number label)
- 创新实训(十一)开发过程中的一些bug汇总
- VGA显示彩条和图片(FPGA)
- 关于#SQLite写注册功能时,数据表查询出错#的问题,如何解决?
- [cloud native | kubernetes] learn more about ingress
猜你喜欢

import torch_ Data view of geometric

A "murder case" caused by ES setting operation

ITK multiresolution image itk:: recursivemultiresolutionpyramidimagefilter

Volume mount and mirror creation

How to balance multiple losses in deep learning?

Summary of question brushing in leetcode sliding window

用PyTorch进行语义分割

实战 | 巧用位姿解算实现单目相机测距

创新实训(十一)开发过程中的一些bug汇总

Freshman girls' nonsense programming is popular! Those who understand programming are tied with Q after reading
随机推荐
Will the next star of PPT for workplace speech be you [perfect summary] at the moment
Mui login database improvement and Ajax asynchronous processing [mui+flask+mongodb+hbuilderx]
VGA显示彩条和图片(FPGA)
jsp跳转问题,不能显示数据库数据,并且不能跳转
大一女生废话编程爆火!懂不懂编程的看完都拴Q了
Bitmap, bloom filter and hash sharding
How to solve the problem of data table query error when SQLite writes the registration function?
The goods are full. You must take this knowledge
import torch_ Geometric loads some common datasets
It is enough to read this article. Web Chinese development
Overview of embedded system 3- development process, learning basis and methods of embedded system
Introduction to application design scheme of intelligent garbage can voice chip, wt588f02b-8s
Multi source BFS problem template (with questions)
Stm32f1 and stm32subeide programming example - device driver -dht11 temperature sensor driver
Five ways to quickly download large files from Google cloud disk
Successful job hopping Ali, advanced learning
【云原生 | Kubernetes篇】Ingress案例实战
torch_ geometric message passing network
章鱼网络进展月报 | 2022.5.1-5.31
Getting to know blob objects