当前位置:网站首页>买不到的数目
买不到的数目
2022-07-26 22:33:00 【Ding Jiaxiong】
题目
小明开了一家糖果店。
他别出心裁:把水果糖包成4颗一包和7颗一包的两种。
糖果不能拆包卖。
小朋友来买糖的时候,他就用这两种包装来组合。
当然有些糖果数目是无法组合出来的,比如要买 10 颗糖。
你可以用计算机测试一下,在这种包装情况下,最大不能买到的数量是17。
大于17的任何数字都可以用4和7组合出来。
本题的要求就是在已知两个包装的数量时,求最大不能组合出的数字。
输入格式
两个正整数 n,m,表示每种包装中糖的颗数。
输出格式
一个正整数,表示最大不能买到的糖数。
数据范围
2≤n,m≤1000,
保证数据一定有解。
输入样例:
4 7
输出样例:
17
思路分析


题解
公式题
#include<iostream>
using namespace std;
int main(){
int p , q;
cin >> p >> q;
cout << (p - 1) * (q - 1) - 1 << endl;
return 0;
}

边栏推荐
- 关于 StatefulWidget,你不得不知道的原理和要点!
- The interviewer asked: this point of JS
- pgsql -&gt; flink cdc -&gt; flink -&gt; Mysql, if a PgSQL CDC
- [postgresql]postgresqlg use generate_ Series() function completes statistics
- np.transpose & np.expand_dims
- [shader realizes swaying effect _shader effect Chapter 4]
- [2016] [paper notes] differential frequency tunable THz technology——
- What is Base64?
- Science | 华盛顿大学利用AI和结构预测设计全新蛋白质
- Lesson 2 of Silicon Valley classroom - building project environment and developing lecturer management interface
猜你喜欢

Hcia-r & s self use notes (19) VLAN configuration and experiment, routing between VLANs

科研太忙无法顾家?陈婷:人生不能只有一个支点

基本的SELECT语句
The memory occupation of the computer is too high after it is turned on (more than 50%)

HCIA-R&S自用笔记(23)DHCP

Hcia-r & s self use notes (20) VLAN comprehensive experiment, GVRP

Real time voice quality monitoring

Too busy with scientific research to take care of your family? Chen Ting: life cannot have only one fulcrum

【2016】【论文笔记】差频可调谐THz技术——

Dajiang Zhitu and CC have produced multiple copies of data. How to combine them into one and load them in the new earth map
随机推荐
Pytorch学习记录(二):张量
Easily implement seckill system with redis! (including code)
第二部分—C语言提高篇_11. 预处理
pgsql -&gt; flink cdc -&gt; flink -&gt; Mysql, if a PgSQL CDC
My SQL is OK. Why is it still so slow? MySQL locking rules
[MySQL] CentOS 7.9 installation and use mysql-5.7.39 binary version
【flask高级】结合源码分析flask中的线程隔离机制
Related functions of strings
Silicon Valley class lesson 5 - Tencent cloud object storage and course classification management
实战项目:Boost搜索引擎
Custom type
What is Base64?
2022年物联网行业有哪些用例?
Use Arthas to locate online problems
Boss; Can flick CDC Oracle finish reading the full amount of data, just like directly fetching data from the database
The nature and proof of the center of gravity of [mathematics] tree
Thousands of tiles' tilt model browsing speeds up, saying goodbye to the embarrassment of jumping out one by one
Introduction to the use of Jerry downloader forced download tool_ Ac695n696nad14ad15 full range support
8 other programming languages -- Recording
Several inventory terms often used in communication