Pentru această operație este nevoie să te autentifici.

Cod sursă (job #131466)

Utilizator avatar P_ERROR Pangratie Andrei P_ERROR IP ascuns
Problemă 2sah (clasele 11-12) Compilator cpp | 0,72 kb
Rundă Arhiva de probleme Status evaluat
Dată 10 mar. 2015 08:47:39 Scor 3
#include <bits/stdc++.h>

using namespace std;

const int MOD = 100003;

void nextT( int &t1, int &t2, int &t3 ){

    int aux = (t1 + t2 + t3) % MOD;
    t1 = t2;
    t2 = t3;
    t3 = aux;
}

int exp3( int n ){
    long long e = 3;
    long long k = 1;

    while( n ){
        if( n & 1 )
            k *= e;

        e = ( e * e ) % MOD;
        n = ( n >> 1 );
    }

    return k;
}

int main()
{
    ifstream f("2sah.in");
    ofstream g("2sah.out");

    int p;
    int n, k;

    f >> p >> n >> k;

    int t1 = 1;
    int t2 = 1;
    int t3 = 2;

    nextT( t1, t2, t3 );

    if( p == 1 ){
        g << exp3( k - 1 ) << endl;
    }
    else
    {

    }

    return 0;
}