From 46424b49ac62c53f785ed85f878169018972ad01 Mon Sep 17 00:00:00 2001 From: Sidhudog <64831792+Sidhudog@users.noreply.github.com> Date: Fri, 2 Oct 2020 14:32:49 +0530 Subject: [PATCH] a small solution changed solution --- 271A - Beautiful Year.cpp | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/271A - Beautiful Year.cpp b/271A - Beautiful Year.cpp index 599145f..7dbb7f4 100644 --- a/271A - Beautiful Year.cpp +++ b/271A - Beautiful Year.cpp @@ -1,24 +1,33 @@ //4022146 Jul 4, 2013 8:34:23 PM fuwutu 271A - Beautiful Year GNU C++0x Accepted 15 ms 0 KB #include - using namespace std; - int main() { - int y; - cin >> y; - while (true) + int n, m, a[4], i; + cin >> n; + m = n + 1; + + for (i = 0; i < 4; i++) { - y += 1; - int a = y / 1000; - int b = y / 100 % 10; - int c = y / 10 % 10; - int d = y % 10; - if (a != b && a != c && a != d && b != c && b != d && c != d) + a[i] = m % 10; + m = m / 10; + } + m=n+1; + while (a[0] == a[1] || a[0] == a[2] || a[0] == a[3] || a[1] == a[2] || a[1] == a[3] ||a[2] == a[3] ) + { + n=m; + m++; + for (i = 0; i < 4; i++) { - break; + a[i] = n % 10; + n = n / 10; } + + } + if(m==n+1) + { + cout<