Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- //macrou
- #define Max(a, b) (a) > (b) ? (a) : (b)
- #define Patrat(x) (x) * (x)
- using namespace std;
- int n;
- int SumaSubmultimi(int n)
- {
- /*1
- s = n * (n+1);
- for(i = 1; i <= n; i++)
- s *= 2;
- */
- //2
- if(n == 1) return 1;
- int s = n * (n+1) * (1 << n-2);
- //1 << k este 2^k
- return s;
- }
- //Functii inline
- inline int Modul(int x)
- {
- if (x < 0) return -x;
- return x;
- }
- int main()
- {
- cin >> n;
- cout << SumaSubmultimi(n) << "\n";
- int m = Max(12, 14);
- cout << m << "\n";
- m = Patrat(3+1);
- cout << m;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement