当前位置:网站首页>Electronic Society C language level 1 30, calculation of last term of arithmetic sequence
Electronic Society C language level 1 30, calculation of last term of arithmetic sequence
2022-06-26 22:46:00 【dllglvzhenfeng】
Electronics Association C Language 1 level 30 、 Calculation of the last term of the arithmetic sequence
OpenJudge - 7654: Calculation of the last term of the arithmetic sequence
OpenJudge - 18: Calculation of the last term of the arithmetic sequence
Mathematical knowledge points column of higher vocational college entrance examination : The general term formula of arithmetic sequence
C++ Code : Method 1
/*
Electronics Association C Language 1 level 30 、 Calculation of the last term of the arithmetic sequence
http://noi.openjudge.cn/math/7654/
http://noi.openjudge.cn/ch0103/18/
Give the first two terms of an arithmetic sequence a1,a2, Please n What is the item? .
Input
a line , Contains three integers a1,a2,n.-100 <= a1,a2 <= 100,0 < n <= 1000.
Output
An integer , That is to say n Item value .
The sample input :1 4 100
Sample output :298
3 6 9 12 15
Mathematical knowledge points column of higher vocational college entrance examination : The general term formula of arithmetic sequence
https://www.bilibili.com/video/BV13U4y1p7ec
*/
#include<iostream>
using namespace std;
int main()
{
int a1,a2,an,n;
cin>>a1>>a2>>n;
// tolerance d=a2-a1=a3-a2=a4-a3=an-an-1
an=a1+(n-1)*(a2-a1);// General term formula of arithmetic sequence
cout<<an;
return 0;
} C++ Code : Method 2
/*
Electronics Association C Language 1 level 30 、 Calculation of the last term of the arithmetic sequence Method 2
http://noi.openjudge.cn/math/7654/
http://noi.openjudge.cn/ch0103/18/
1047: Judge whether it can be 3,5,7 to be divisible by --- good
https://blog.csdn.net/weixin_43877387/article/details/118456563
*/
#include<iostream>
using namespace std;
int main()
{
int a1,a2,n,d;
cin>>a1>>a2>>n;
d=a2-a1;
cout<<a1+(n-1)*d;
return 0;
}python3 Code :
a1,a2,n=map(int,input().split())
d=a2-a1
an=a1+(n-1)*d
print(an)Electronic Society junior programming grade test
https://blog.csdn.net/dllglvzhenfeng/category_11735875.html
Electronics Association C Language 1 level 30 、 Calculation of the last term of the arithmetic sequence
OpenJudge - 7654: Calculation of the last term of the arithmetic sequence
OpenJudge - 18: Calculation of the last term of the arithmetic sequence
Mathematical knowledge points column of higher vocational college entrance examination : The general term formula of arithmetic sequence
Electronics Association Youth software programming level test C Language over the years
Electronics Association C Language Real and simulated questions
Electronics Association C Language 1 level 5 、 Judge whether it can be 3 ,5 ,7 to be divisible by
Electronics Association C Language 1 level 6 、 Cycling and walking
Electronics Association C Language 1 level 7 、 Draw a rectangular
Electronics Association C Language 1 level 18 、 Calculate postage
Electronics Association C Language 1 level 19 、 Find the sum and mean of integers
Electronics Association C Language 1 level 21 、 The problem of logical judgment Enter three numbers a,b,c, The largest output
Electronics Association C Language 1 level 23 、 Judge the average leap year
边栏推荐
- Unity布料系統_Cloth組件(包含動態調用相關)
- nmap参数详解
- [cloud native topic -51]:kubesphere cloud Governance - operation - step by step deployment of microservice based business applications - database middleware redis microservice deployment process
- Data governance does everything
- Is there any risk in opening a new bond registration account? Is it safe?
- YOLOv6:又快又准的目標檢測框架開源啦
- Is it safe to open an account and buy stocks? Who knows
- Unity: the referenced script (unknown) on this behavior is missing“
- Leetcode (122) - the best time to buy and sell stocks II
- VB. Net class library (Advanced - 2 overload)
猜你喜欢

360 mobile assistant is the first to access the app signature service system to help distribute privacy and security

Parsing complex JSON in fluent

leetcode:141. 环形链表【哈希表 + 快慢指针】

Weaving dream collection plug-ins are recommended to be free collection plug-ins

vulnhub之dc8

Restfultoolkitx of idea utility plug-in -- restful interface debugging

數據清洗工具flashtext,效率直接提昇了幾十倍數
![leetcode:1567. 乘积为正数的最长子数组长度【dp[i]表示以i结尾的最大长度】](/img/a4/c5c31de7a0a3b34a188bfec0b5d184.png)
leetcode:1567. 乘积为正数的最长子数组长度【dp[i]表示以i结尾的最大长度】

leetcode:6103. 从树中删除边的最小分数【dfs + 联通分量 + 子图的值记录】
![leetcode:1567. Length of the longest subarray whose product is a positive number [dp[i] indicates the maximum length ending with I]](/img/a4/c5c31de7a0a3b34a188bfec0b5d184.png)
leetcode:1567. Length of the longest subarray whose product is a positive number [dp[i] indicates the maximum length ending with I]
随机推荐
Different subsequence problems I
【混合编程jni 】第十一篇之JNA详情
DAST 黑盒漏洞扫描器 第五篇:漏洞扫描引擎与服务能力
FPGA -vga display
What is the “ How to remove a custom form list?
[hybrid programming JNI] details of JNA in Chapter 11
Configuring assimp Library in QT environment (MinGW compiler)
在Flutter中解析复杂的JSON
leetcode - 买卖股票的最佳时机
YOLOv6:又快又准的目標檢測框架開源啦
360 mobile assistant is the first to access the app signature service system to help distribute privacy and security
[mathematical modeling] spanning tree based on Matlab GUI random nodes [including Matlab source code 1919]
NPM command prompt error: eacces: permission denied
Installation avec homebrew dans un environnement Mac OS [email protected]
L'outil de nettoyage des données flashtext améliore directement l'efficacité de plusieurs dizaines de fois
leetcode:6107. 不同骰子序列的数目【dp六个状态 + dfs记忆化】
Unity布料系統_Cloth組件(包含動態調用相關)
用C#通过sql语句操作Sqlserver数据库教程
npm 命令提示Error: EACCES: permission denied
树莓派初步使用