Advertisement
J00ker

E

Oct 7th, 2014
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2. //macrou
  3. #define Max(a, b) (a) > (b) ? (a) : (b)
  4. #define Patrat(x) (x) * (x)
  5.  
  6. using namespace std;
  7.  
  8. int n;
  9.  
  10. int SumaSubmultimi(int n)
  11. {
  12. /*1
  13. s = n * (n+1);
  14. for(i = 1; i <= n; i++)
  15. s *= 2;
  16. */
  17.  
  18. //2
  19. if(n == 1) return 1;
  20. int s = n * (n+1) * (1 << n-2);
  21. //1 << k este 2^k
  22. return s;
  23. }
  24. //Functii inline
  25. inline int Modul(int x)
  26. {
  27. if (x < 0) return -x;
  28. return x;
  29. }
  30.  
  31. int main()
  32. {
  33. cin >> n;
  34. cout << SumaSubmultimi(n) << "\n";
  35. int m = Max(12, 14);
  36. cout << m << "\n";
  37. m = Patrat(3+1);
  38. cout << m;
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement