제출 #1364246

#제출 시각아이디문제언어결과실행 시간메모리
1364246jojeonghoonRUN Sequence (KAISTRUN26SPRING_B)C++20
100 / 100
1 ms344 KiB
#include <bits/stdc++.h>
#define ll long long
#define int ll
#define vi vecotr<int>
#define rep(i,s,e) for(int i=(s); i<=(e); i++)
#define arr2 array<int,2>
#define arr3 array<int,3>
using namespace std;

int D[111];

int Naive(int a, int b, int N){
    set<int>ret;
    rep(i,1,a) rep(j,1,b) ret.insert(i*D[N-2]+j*D[N-1]);
    return ret.size();
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);

    D[1]=1;D[2]=1;rep(i,3,100) D[i]=D[i-1]+D[i-2];

    int a,b,N;
    cin>>a>>b>>N;

    if(N>100 || D[N-1]>a || D[N-1]>b){
        cout<<a*b;
        return 0;
    }

    if(N==3){
        cout<<a+b-1;
        return 0;
    }
    if(N==4){
        cout<<a+b*2-2;
        return 0;
    }

    int ans = (a/D[N-1]+b/D[N-2]-1) * D[N-1]*D[N-2];
    a%=D[N-1]; b%=D[N-2];
    ans += a*D[N-2] + b*D[N-1];
    


    //if(ans!=ANS) cout<<"NO "<<ANS<<"\n";
    cout<<ans;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…