View Code of Problem 18

#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
    int times;
    while(cin>>times){
           if(times<3)
            cout<<0<<endl;
           else {
            int cnt=1,temp=0,k=0;
            times-=2;
            while(times--)
            {
                k=cnt+temp;
                temp=cnt;
                cnt=k;
            }
            cout<<k<<endl;
           }

    }
return 0;
}

Double click to view unformatted code.


Back to problem 18