Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: KanemiyaKana

Problemset: อนุกรม

Language: cpp

Time: 0.004 second

Submitted On: 2026-09-24 15:46:54

#include <iostream>
#include <string>
using namespace std;

long long serieslocation(int rank)
{
    long long returnvalue = 0;
    long long starter1 = 0;
    long long starter2 = 1;

    for (int i = 0; i < rank - 1; i++)
    {                               // i | 1  2  3  4  5
        long long temp = starter1;  //   | 0  0  1  1  2
        starter1 = starter2;        //   | 0  1  1  2  3
        starter2 = temp + starter2; //   | 1  1  2  3  5
    }

    returnvalue = starter2;
    return returnvalue;
}

int main()
{
    int input;
    cin >> input;
    if (0 >= input || input > 100)
    {
        return 0;
    }
    else
    {
        long long output = serieslocation(input);
        cout << output;
    }
}