Monday, March 16, 2015

488A - Giga Tower (Codeforces)

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define pf printf
#define sf scanf
typedef long long ll;

int check(ll n)
{
    int count = 0;
    if(n<0)
    {
          n=-n;
    }
    while(n)
    {
        if(n%10==8)
        {
            count++;
        }
        n=n/10;
    }
    return count;
}

int main()
{
    ll a;
    int count, f;
    cin >> a;
    f=0;
    while(1)
    {
        a++;
        f++;
        count = check(a);
        if(count>=1)
        {
           break;
        }
    }
    cout<< f << endl;
}

No comments:

Post a Comment

Compare equality of two string in C

#include <stdio.h> #include<string.h> int main() {     char* country = "Bangladesh";     char* country2;     ...