Cod sursa(job #3030623)

Utilizator AlexMoto2006Motoasca Alexandru-Lucian AlexMoto2006 Data 17 martie 2023 19:20:53
Problema Iepuri Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.94 kb
#include <fstream>
#include <deque>
typedef long long ll;

using namespace std;

ifstream cin("iepuri.in");
ofstream cout("iepuri.out");
deque <int> q;
int main()
{
    int k;
    cin >> k;
    for (int i = 1; i <= k; i++)
    {
            int x, y, z, a, b, c, n;
            cin >> x >> y >> z >> a >> b >> c >> n;
            q.push_back(x);
            q.push_back(y);
            q.push_back(z);
            n -= 2;
            while (n)
            {
                int aux = q.front();
                q.pop_front();
                int aux2 = q.front();
                q.pop_front();
                int aux3 = q.front();
                q.push_front(aux2);
                q.push_back(a * aux3 + b * aux2 + c * aux);
                n--;
            }
            cout << q.back()<<"\n";
                while (!q.empty())
                {
                    q.pop_back();
                }
    }
    return 0;
}