Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <math.h>
- using namespace std;
- long int calc(long int n, long int m, long int a)
- {
- if (n<=2)
- {
- return a;
- }
- long int fn = pow((3 * a), m) * calc(n-1, m, a);
- long int fx = pow((4 * a), m - 1) * calc(n - 3, m, a);
- return fn + fx;
- }
- int main()
- {
- int n;
- cin>>n;
- for (int i = 1; i <= n; i++)
- {
- long int n,m,a;
- cin >> n >> m >> a;
- cout << calc(n,m,a) <<"\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment