Emiliatan

e156 - 3

Apr 13th, 2019
701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. /* e156 - 3        */
  2. /* AC (2ms, 100KB) */
  3. #include <cstdio>
  4.  
  5. using namespace std;
  6.  
  7. unsigned int n;
  8.  
  9. typedef unsigned int (*fun)(unsigned int);
  10.  
  11. unsigned int Solution_Teminator(unsigned n)
  12. {
  13.     return 0;
  14. }
  15.  
  16. unsigned int Sum_Solution(unsigned int n)
  17. {
  18.     static fun f[2] = {Solution_Teminator, Sum_Solution};
  19.     return n + f[!!n](n - 1);
  20. }
  21.  
  22. int main()
  23. {
  24.     scanf("%u", &n);
  25.     printf("%u", Sum_Solution(n));
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment