codeforces 617A solution in c/c++

// 617A.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

//#include "pch.h"
#include <iostream>
using namespace std;
int main()
{
int n,a,b,c,d,e,cc=0,aa=0;
cin >> n;
a = 1;
b = 2;
c = 3;
d = 4;
e = 5;
while (1)
{
    if(n>=e)
        {
            cc=n%e;
            aa=aa+n/e;
            n=cc;
            if(cc==0)
            {
                cout<<aa;
                break;
            }
        }
        else if(cc>=d||n>=d)
        {
            cc=cc%d;
            aa=aa+n/d;
            n=cc;
            if(cc==0)
            {
                cout<<aa;
                break;
            }
        }
        else if(cc>=c||n>=c)
        {
            cc=cc%c;
            aa=aa+n/c;
            n=cc;
            if(cc==0)
            {
                cout<<aa;
                break;
            }
        }
        else if(cc>=b||n>=b)
        {
            cc=cc%b;
            aa=aa+n/b;
            n=cc;
            if(cc==0)
            {
            cout<<aa;
            break;
            }
        }
        else if(cc>=a||n>=a)
        {
            cc=cc%a;
            aa=aa+n/a;
            n=cc;
            if(cc==0)
            {
                cout<<aa;
                break;
            }

        }

}


}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
//

Comments

Popular posts from this blog

codeforces 472A problem solution in simple c/c++

codeforces 339A solution in c/c++

codeforces 520A problem solution in c/c++