View Code of Problem 3691

 
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
 
 
int main()
{
    int n,i,x,y;
    int a[] = {0,0,1,7,4,2,0,8,10,18,22,20,28,68,88,108,188,200,208,288,688,888};
    while(cin>>n)
    {
       if(n<= 21)
           cout<<a[n]<<endl;
        else
        {
            x = (n - 14) % 7;
            y = (n - 14) / 7;
            cout<<a[x + 14];
            while(y--)
            {
                cout<<8;
            }
            cout<<endl;
        }
        
        
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 3691