Submission #35203249


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
signed main() {
	int k;
	cin>>k;
	k--;
	vector<int> now;
	now.push_back(1);
	while(k--) {
		bool flag=0;
		for(int i=0;i<now.size()-1;i++)
			if(now[i]<=now[i+1]&&now[i]!=9) {
				now[i]++,flag=1;
				for(int j=i-1;j>=0;j--)
					now[j]=max(0,now[j+1]-1);
				break;
			}
		if(!flag) {
			if(now.back()==9) {
				now.push_back(1);
				for(int i=0;i<now.size()-1;i++)
					now[i]=0;
			}
			else {
				now.back()++;
				for(int j=(int)now.size()-2;j>=0;j--)
					now[j]=max(0,now[j+1]-1);
			}
		}
	}
	for(int i=now.size()-1;i>=0;i--)
		cout<<now[i];
	cout<<endl;
	return 0;
}

Submission Info

Submission Time
Task D - Lunlun Number
User cxm1024
Language C++ (GCC 9.2.1)
Score 400
Code Size 654 Byte
Status AC
Exec Time 5 ms
Memory 3612 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:11:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   11 |   for(int i=0;i<now.size()-1;i++)
      |               ~^~~~~~~~~~~~~
./Main.cpp:21:18: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   21 |     for(int i=0;i<now.size()-1;i++)
      |                 ~^~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 27
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All 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 AC 5 ms 3540 KiB
etc_02.txt AC 2 ms 3456 KiB
etc_03.txt AC 2 ms 3520 KiB
etc_04.txt AC 2 ms 3464 KiB
etc_05.txt AC 2 ms 3392 KiB
etc_06.txt AC 2 ms 3456 KiB
etc_07.txt AC 2 ms 3460 KiB
etc_08.txt AC 2 ms 3396 KiB
etc_09.txt AC 2 ms 3548 KiB
etc_10.txt AC 2 ms 3552 KiB
etc_11.txt AC 2 ms 3500 KiB
etc_12.txt AC 1 ms 3456 KiB
etc_13.txt AC 2 ms 3536 KiB
etc_14.txt AC 2 ms 3552 KiB
etc_15.txt AC 2 ms 3540 KiB
etc_16.txt AC 2 ms 3452 KiB
etc_17.txt AC 2 ms 3500 KiB
etc_18.txt AC 2 ms 3552 KiB
rand_01.txt AC 5 ms 3552 KiB
rand_02.txt AC 2 ms 3480 KiB
rand_03.txt AC 2 ms 3612 KiB
rand_04.txt AC 2 ms 3396 KiB
rand_05.txt AC 2 ms 3552 KiB
sample_01.txt AC 2 ms 3456 KiB
sample_02.txt AC 2 ms 3588 KiB
sample_03.txt AC 2 ms 3548 KiB
sample_04.txt AC 2 ms 3548 KiB