Codeforces 271A Beautiful Year Solution

Solve in C:

#include<stdio.h>
int main()
{

    int y,a,b,c,d,count=0;
    while(scanf("%d",&y)!=EOF)
    {
        while(y>0)
        {
            y++;
            a=y/1000;
            b=(y%1000)/100;
            c=((y%1000)%100)/10;
            d=((y%1000)%100)%10;

            if(a!=b&&a!=c&&a!=d&&d!=c&&d!=b&&c!=b)
                break;
        }
        printf("%d\n",y);
    }


}

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.