38352023-03-03 10:54:07hackemonToronyépítés (1,1,3,3)cpp17Elfogadva 50/5013ms10580 KiB
#include <bits/stdc++.h>
using namespace std;
//using namespace std::chrono;

#define pii pair<int,int>
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vvi vector<vi>
#define vvb vector<vb>
#define vvl vector<vl>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define fScan {ios_base::sync_with_stdio(false); cin.tie(NULL);}
#define rep(i, a, b) for(int i = a; i < (b); i++)
#define REP(i, n) for(int i = 0;i <(n); i++)
using ll = long long;
using ld = long double;
ll mod = 1000000007;

const char ny =  '\n';

bool prime(ll a) {
    if (a==1) return 0;
    for (int i=2;i*i<=a;++i)
    {
        if (a%i==0) return 0;
    }
    return 1;
}

ll gcd(ll a,ll b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}

ll min(int a, ll b) {
    if(a< b) return a;
    else return b;
}


void solve() { 
    int n;
    cin >> n;
    vector<int> dp(n+1);
    dp[0] = 0, dp[1] = 2, dp[2] = 4, dp[3] = 10;
    for(int i = 4;i <= n;i++ ) {
        dp[i] = (dp[i-1]*2+dp[i-3]*2)%20210108;
    } 
    cout << dp[n] << ny;
    }


int main()
{
    fScan

    int t = 1;
    //comment out if necessary
    //cin>> t;


    //auto start = high_resolution_clock::now();
    while(t-- ) {
        solve();
    }
    //auto end = high_resolution_clock::now();
    //auto dur = duration_cast<milliseconds>(end-start);
    //cout<< "runtime: " << dur.count() << " milliseconds" << '\n';
    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/03ms1828 KiB
2Elfogadva0/03ms2064 KiB
3Elfogadva3/33ms2264 KiB
4Elfogadva3/32ms2340 KiB
5Elfogadva4/43ms2548 KiB
6Elfogadva4/42ms2624 KiB
7Elfogadva4/413ms10308 KiB
8Elfogadva4/44ms3572 KiB
9Elfogadva4/42ms2840 KiB
10Elfogadva4/42ms2940 KiB
11Elfogadva4/44ms4580 KiB
12Elfogadva4/413ms10580 KiB
13Elfogadva4/410ms9852 KiB
14Elfogadva4/46ms5820 KiB
15Elfogadva2/22ms3492 KiB
16Elfogadva2/22ms3376 KiB