1 条题解

  • 0
    @ 2024-4-6 13:47:18
    /*
    公式:
    末项=首项+(项数-1)*公差
    项数=(末项-首项)/公差+1
    首项=末项-(项数-1)* 公差
    和=(首项+末项)*项数/2
    */
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int a1,a2,n;	
        scanf("%d%d%d",&a1,&a2,&n);
        printf("%d",a1+(a2-a1)*(n-1));//末项=首项+(项数-1)*公差
        return 0;
    }
    

    信息

    ID
    36
    时间
    1000ms
    内存
    128MiB
    难度
    4
    标签
    递交数
    23
    已通过
    16
    上传者