1 条题解

  • 0
    @ 2026-2-3 14:23:30

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int n,sum=0,y=1;
        cin>>n;
        while(n--){
            sum+=y;
            if(n==0) break;
            y++; 
        }
        cout<<sum;
        return 0;
    } 
    

    Python :

    # coding=utf-8
    n=int(input())
    s=0
    for i in range(n+1):
        s=s+i
    print(s)
        
    
    • 1

    信息

    ID
    199
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者