Codeforces Beautiful Year
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int ar[11];
bool isyear(int n)
{
memset(ar, 0, sizeof(ar));
while(n)
{
ar[n%10]++;
if(ar[n%10] > 1) return false;
n/=10;
}
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
int n;
while(cin >> n)
{
int x,y,z;
for(int i=n+1; ; i++)
{
if(isyear(i))
{
cout << i << "\n";
break;
}
}
}
return 0;
}
using namespace std;
typedef long long LL;
int ar[11];
bool isyear(int n)
{
memset(ar, 0, sizeof(ar));
while(n)
{
ar[n%10]++;
if(ar[n%10] > 1) return false;
n/=10;
}
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
int n;
while(cin >> n)
{
int x,y,z;
for(int i=n+1; ; i++)
{
if(isyear(i))
{
cout << i << "\n";
break;
}
}
}
return 0;
}
Comments
Post a Comment