Cod sursa(job #3215555)

Utilizator AndriskaSzabo Andras-Albert Andriska Data 15 martie 2024 09:51:42
Problema Iepuri Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.51 kb
// nyuszik(kurvaanyjuk).cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    ifstream f("iepuri.in");
    ofstream g("iepuri.out");
    int t, x, y, z, a, b, c, n,p;
    f >> t;
    for (int i = 0; i < t; i++) {
        f >> x >> y >> z >> a >> b >> c >> n;
        for(int i=0;i<n-2;i++){
            while (x < y || y < z) {
                if (x < y) {
                    p = x;
                    x = y;
                    y = p;
                }
                if (y < z) {
                    p = y;
                    y = z;
                    z = p;
                }
            }
            p = x * a + y * b + z * c;
            z = y;
            y = x;
            x = p;
        }
        g << p;
        g << endl;
    }
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file