Advertisement
Emiliatan

e156 - 1

Apr 13th, 2019
669
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. /* e156 - 1        */
  2. /* AC (3ms, 292KB) */
  3. #include <cstdio>
  4.  
  5. using namespace std;
  6.  
  7. unsigned int n;
  8.  
  9. class Temp
  10. {
  11.     public:
  12.         Temp(){++N; Sum += N;}
  13.  
  14.         static void Reset() {N = 0; Sum = 0;}
  15.         static unsigned int GetSum() {return Sum;}
  16.  
  17.     private:
  18.         static unsigned int N;
  19.         static unsigned int Sum;
  20. };
  21. unsigned int Temp::N = 0;
  22. unsigned int Temp::Sum = 0;
  23.  
  24. unsigned int Sum_Solution(unsigned int n)
  25. {
  26.     Temp::Reset();
  27.  
  28.     Temp *a = new Temp[n];
  29.     delete []a;
  30.     a = NULL;
  31.  
  32.     return Temp::GetSum();
  33. }
  34.  
  35. int main()
  36. {
  37.     scanf("%u", &n);
  38.     printf("%u", Sum_Solution(n));
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement