79712024-01-12 09:30:41CsongiTáblajátékcpp17Partially correct 38/503ms3556 KiB
#include <iostream>
#include <bits/stdc++.h>
#include <bitset>

using namespace std;


void binaris(unsigned long int n)
{
    if (n / 2 != 0) {
        binaris(n / 2);
    }
    printf("%d", n % 2);
}

int main()
{
    short int k;
    cin >> k;
    vector<short int> szamok(k);
    unsigned long int jelenmezo = 0;
    double jelensor = 0;
    for (short int i = 0; i < k; i++)
    {
        cin >> szamok[i];
        switch (szamok[i])
        {
        case 0:
            jelensor++;
            if (jelenmezo != 0)
                jelenmezo *= 2;
            break;
        case 1:
            jelensor++;
            jelenmezo = (jelenmezo*2)+1;
            break;
        case 2:
            jelenmezo = ceil(jelenmezo / 2);
            jelensor--;
            break;
        case 3:
            if (jelenmezo != 0)
                jelenmezo--;
            break;
        case 4:
            jelenmezo++;
            break;
        }
    }
    cout << jelensor << endl;
    binaris(jelenmezo);
}
SubtaskSumTestVerdictTimeMemory
base38/50
1Accepted0/03ms1876 KiB
2Accepted0/03ms2120 KiB
3Accepted3/33ms2204 KiB
4Accepted3/33ms2152 KiB
5Accepted3/33ms2280 KiB
6Partially correct1/33ms2528 KiB
7Accepted3/33ms2732 KiB
8Accepted3/33ms2792 KiB
9Accepted3/33ms2816 KiB
10Partially correct1/33ms3032 KiB
11Accepted3/33ms3156 KiB
12Partially correct1/33ms3512 KiB
13Accepted4/43ms3456 KiB
14Partially correct1/43ms3456 KiB
15Accepted4/43ms3524 KiB
16Partially correct1/43ms3552 KiB
17Accepted4/43ms3556 KiB