1 solutions

  • 0
    @ 2025-11-5 19:36:22

    C :

    #include<stdio.h>
    #define maxn 100000+1000
    int main(){
    	long long int n,s;
    	while(scanf("%lld",&n)!=EOF){
    		s = n * (n+1) * (2 * n +1)/6;
    		printf("%lld\n",s);
    	}
        return 0;
    } 
    

    C++ :

    #include<stdio.h>
    int main(){
    	long long int  n,s;
    	while(scanf("%lld",&n)!=EOF){
    		s = n * (n+1) * (2 * n +1)/6;
    		printf("%lld\n",s);
    	}
        return 0;
    } 
    
    • 1

    Information

    ID
    19445
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By