CCCPaste

Untitled

#include 

using namespace std;

int main() {
    int number;
    cin >> number;
    long long N;
    cin >> N;
    int a = number / 100;
    int b = (number / 10) % 10;
    int c = number % 10;
    if(N <= 3) {
        if(N == 1) {
            cout << a ;
        }
        else if(N == 2) {
            cout << b;
        }
        else {
            cout << c;
        }
        return 0;
    }
    int pc;
    for(int i = 3; i < N; i++) {
        pc = c;
        c = (a + b + c) % 10;
        a = b;
        b = pc;
    }
    cout << c << endl;
    return 0;
}