Submission #11550250


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int K;
//---------------------------------------------------------------------------------------------------
string increment(string from) {
	int N = from.size();

	rrep(i, N - 1, 1) {
		int cu = from[i] - '0';
		int nxt = from[i - 1] - '0';

		if (cu < 9 && abs(cu + 1 - nxt) <= 1) {
			from[i]++;
			rep(j, i + 1, N) from[j] = max('0', (char)(from[j - 1] - 1));
			return from;
		}
	}

	int top = from[0] - '0';
	
	if (top < 9) {
		from[0]++;
		rep(j, 1, N) from[j] = max('0', (char)(from[j - 1] - 1));
		return from;
	}

	string res = "1";
	rep(i, 0, N) res += "0";
	return res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> K;

	string ans = "1";
	rep(k, 0, K - 1) ans = increment(ans);
	cout << ans << endl;
}





Submission Info

Submission Time
Task D - Lunlun Number
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2119 Byte
Status
Exec Time 8 ms
Memory 256 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All 400 / 400 etc_01.txt, etc_02.txt, etc_03.txt, etc_04.txt, etc_05.txt, etc_06.txt, etc_07.txt, etc_08.txt, etc_09.txt, etc_10.txt, etc_11.txt, etc_12.txt, etc_13.txt, etc_14.txt, etc_15.txt, etc_16.txt, etc_17.txt, etc_18.txt, rand_01.txt, rand_02.txt, rand_03.txt, rand_04.txt, rand_05.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
etc_01.txt 1 ms 256 KB
etc_02.txt 1 ms 256 KB
etc_03.txt 1 ms 256 KB
etc_04.txt 1 ms 256 KB
etc_05.txt 1 ms 256 KB
etc_06.txt 1 ms 256 KB
etc_07.txt 1 ms 256 KB
etc_08.txt 1 ms 256 KB
etc_09.txt 1 ms 256 KB
etc_10.txt 1 ms 256 KB
etc_11.txt 1 ms 256 KB
etc_12.txt 1 ms 256 KB
etc_13.txt 2 ms 256 KB
etc_14.txt 1 ms 256 KB
etc_15.txt 3 ms 256 KB
etc_16.txt 3 ms 256 KB
etc_17.txt 3 ms 256 KB
etc_18.txt 3 ms 256 KB
rand_01.txt 8 ms 256 KB
rand_02.txt 8 ms 256 KB
rand_03.txt 8 ms 256 KB
rand_04.txt 8 ms 256 KB
rand_05.txt 8 ms 256 KB
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
sample_04.txt 8 ms 256 KB