当前位置:网站首页>L1-080 乘法口诀数列 (20 分)
L1-080 乘法口诀数列 (20 分)
2022-04-22 23:53:00 【NEFU AB-IN】
Powered by:NEFU AB-IN
文章目录
L1-080 乘法口诀数列 (20 分)
-
题意
本题要求你从任意给定的两个 1 位数字 a 1 和 a 2开始,用乘法口诀生成一个数列,规则为从 a 1开始顺次进行,每次将当前数字与后面一个数字相乘,将结果贴在数列末尾。如果结果不是 1 位数,则其每一位都应成为数列的一项。
-
思路
v.insert(v.end(), tmp.begin(), tmp.end())可以将tmp全部元素插入到v后面
v(4, 1)定义一个长度为4,全是1的vector -
代码
/* * @Author: NEFU AB-IN * @Date: 2022-04-22 19:22:10 * @FilePath: \ACM\GPLT\L1-080.cpp * @LastEditTime: 2022-04-22 19:30:12 */ #include <bits/stdc++.h> using namespace std; #define int long long #define MP make_pair #define SZ(X) ((int)(X).size()) #define IOS \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define DEBUG(X) cout << #X << ": " << X << endl; typedef pair<int, int> PII; const int INF = 0x3f3f3f3f; int a1, a2, n; vector<int> v; void cale(int x) { vector<int> tmp; while (x) { tmp.push_back(x % 10); x /= 10; } reverse(tmp.begin(), tmp.end()); v.insert(v.end(), tmp.begin(), tmp.end()); } signed main() { IOS; cin >> a1 >> a2 >> n; v.push_back(a1); v.push_back(a2); int p1 = 0, p2 = 1; while (SZ(v) < n) { int x = v[p1], y = v[p2]; int ans = x * y; cale(ans); p1++; p2++; } for (int i = 0; i < n; ++i) { cout << v[i] << " "[i == n - 1]; } return 0; }
版权声明
本文为[NEFU AB-IN]所创,转载请带上原文链接,感谢
https://ab-in.blog.csdn.net/article/details/124353467
边栏推荐
- 用C语言编写一个俄罗斯方块小游戏
- Online fox U3D client game configuration loading failed couldn't connect to server
- Vscode uses emmylua plug-in to debug unity project tolua code
- 彻底解决Failed to execute goal on project xxxxx
- Traceup | a powerful tool to reduce stress and achieve more success and help you get rid of work anxiety
- ssh: connect to host 172.31.8.132 port 22: Connection refused
- Thought of reducing Governance -- detailed summary of binary search
- [dvcon2020] simulation acceleration method based on multithreaded UVM test platform
- 【Objective-C 高级编程】—— GCD
- 条件判断(whilec循环&for&switch循环&if-else判断)
猜你喜欢
![[perseverance challenge] PCIe ask and answer every day (filed on February 2022)](/img/f5/986fed0345053371b464972997c276.png)
[perseverance challenge] PCIe ask and answer every day (filed on February 2022)
![[PCIe 6.0] new features of PCIe 6.0 - detailed explanation of dmwr (deferred memory write)](/img/4e/980e1eacee42a431823d0576f2e200.png)
[PCIe 6.0] new features of PCIe 6.0 - detailed explanation of dmwr (deferred memory write)

LeetCode 1446 - 1449
![FileNotFoundError: [Errno 2] No such file or directory: 'image/1.jpg'问题解决](/img/72/dca1064713646f909c4a7a8567a742.png)
FileNotFoundError: [Errno 2] No such file or directory: 'image/1.jpg'问题解决

Install the most complete version of ActiveMQ under the official website in 2022 and the official website access method

LabVIEW控制电脑关机、休眠、注销和重启

80386汇编_全局描述表GDT介绍

ssh: connect to host 172.31.8.132 port 22: Connection refused
![[perseverance challenge] PCIe asks and answers every day (filed on March 2022)](/img/3c/b23b90c92a82922a710623b1142412.png)
[perseverance challenge] PCIe asks and answers every day (filed on March 2022)

51 single chip microcomputer learning_ 4-2 nixie tube dynamic display
随机推荐
【Pygame小游戏】Chrome上的小恐龙竟可以用代码玩儿了?它看起来很好玩儿的样子~
Reg regular expression learning notes
VsCode使用EmmyLua插件调试Unity工程ToLua代码
共轭梯度法(Conjugate Gradients)(4)
程序设计语言基础(1)
The implementation principle and function of closure and memory leakage
人们对于产业互联网的认识越来越清晰,越来越接近产业互联网
People's understanding of the industrial Internet is becoming clearer and closer to the industrial Internet
FileNotFoundError: [Errno 2] No such file or directory: 'image/1. Jpg 'problem solving
[dvcon2020] automatic generation method of UVM sequence based on ral
Merge two ordered arrays
FileNotFoundError: [Errno 2] No such file or directory: 'image/1.jpg'问题解决
[perseverance challenge] PCIe ask and answer every day (filed on February 2022)
Django创建表结构及对数据库增删改查
[day22] - [linked list] intersecting linked list
MySQL索引的语法是什么
FileNotFoundError: [Errno 2] No such file or directory: 'image/1. Jpg 'problem solving
unbuntu18. 04 installing gamit10 71 problem solution
云计算仿真框架CloudSim介绍(截图版)
Bonner ultrasonic sensor t30uxda