Cod sursa(job #3158971)

Utilizator MR0L3eXMaracine Constantin Razvan MR0L3eX Data 20 octombrie 2023 12:18:30
Problema Iepuri Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.62 kb
#include <bits/stdc++.h>

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    freopen("iepuri.in", "r", stdin);
    freopen("iepuri.out", "w", stdout);

    const int MOD = 666013;
    int tt = 1;
    std::cin >> tt;
    while (tt--) {
        int x, y, z, a, b, c, n;
        std::cin >> x >> y >> z >> a >> b >> c >> n;
        std::vector<int> dp(n + 1);
        dp[0] = x;
        dp[1] = y;
        dp[2] = z;
        for (int i = 3; i <= n; ++i) {
            dp[i] = a * dp[i - 1] + b * dp[i - 2] + c * dp[i - 3];
        }
        std::cout << dp[n] << "\n";
    }
    return 0;
}