Advertisement
juanjo12x

UVA_12149_Feynman

Aug 9th, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <cstring>
  5. #include <string>
  6. #include <cctype>
  7. #include <stack>
  8. #include <queue>
  9. #include <list>
  10. #include <vector>
  11. #include <map>
  12. #include <set>
  13. #include <sstream>
  14. #include <stdlib.h>
  15. #include <cmath>
  16. #define LL unsigned long long
  17. using namespace std;
  18.  
  19. int main() {
  20.     int n;
  21.     while(scanf("%d",&n)){
  22.         if(n==0) break;
  23.         int result=(n*(n+1)*((2*n)+1))/6;
  24.         printf("%d\n",result);
  25.     }; 
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement