当前位置:网站首页>*1-5 OJ 642 Russian Multiplication
*1-5 OJ 642 Russian Multiplication
2022-08-09 14:48:00 【Ye Xiaobai】
题目描述

输入

输出

样例输入

样例输出

源代码
#include <iostream>
using namespace std;
int calculate(int n, int m) {
int s = 0;
while (n != 1) {
if (n % 2 != 0) {
cout << m << " " << "+" << " ";
s += m;
}
n = n / 2;
m = 2 * m;
}
s += m;//把最后n=1时的m加上
cout << m << " " << "=" << " " << s << endl;
return 0;
}
int main() {
int n, m;
cin >> n >> m;
calculate(n, m);
return 0;
}
关于这题
Pay attention to the format required for the title The output required is a formula
边栏推荐
- How to adjust the spacing between numbers and text in Word?
- Analysis of SEATA Distributed Transaction Framework
- Using the NVIDIA Kaolin Wisp reconstruction of 3 d scene
- typeorm 批量插入数据优化和插入冲突操作
- 内容社区行业搜索最佳实践
- Jetpack Compose - Image using Coli load network Image (including GIF, SVG)
- Xshell建立SSH隧道连接
- vs how to use a Button to link to another page
- 零基础学习CANoe Panel 设计目录
- Shell course summary
猜你喜欢
随机推荐
RHCE课程总结
Flex for openharmony container components
word编号和文本间距过大
Dry+Bean+Dataset R language data analysis, report in English
C语言 猜数字游戏 (含代码并详细注释)
*3-2 CCF 2014-09-2 画图
汇编语言学习(十)常用指令总结
阿里巴巴开源大规模稀疏模型训练/预测引擎DeepRec
Operating system migration practice deploying MySQL database on openEuler
apt-cache 命令
Mysql seven connection query methods
C语言 函数问题
使用Connection对象连接管理事务
实现H5网页授权
【视频编码学习】——SAD和SATD
[Video coding learning] - SAD and SATD
Kotlin入门,应从“这些”学起。
RHCE课程总结
面试官:请说说什么是BFC?大白话讲清楚
汇编语言学习(七)









