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 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.