Submission #55797000


Source Code Expand

N = gets.to_i
if N<=10
	p N-1
	exit
end

n = 10
K = (2..).find{|k|
	znz = (k-1)/2
	dn = 9*10.pow(znz)
	next true if N<n+dn
	n += dn
	next false
}
D = ((K+1)/2).times.map{|i|
	k = (K-(i+1)*2+1)/2
	dn = 10.pow(k)
	d = i==0 ? 1 : 0
	while n+dn<N
		n += dn
		d += 1
	end
	next d
}
R = D.reverse
R.shift if 0<K&1
puts (D+R)*''

Submission Info

Submission Time
Task D - Palindromic Number
User ds14050
Language Ruby (ruby 3.2.2)
Score 350
Code Size 349 Byte
Status AC
Exec Time 42 ms
Memory 17424 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 3
AC × 20
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_1_00.txt, 01_random_1_01.txt, 01_random_1_02.txt, 01_random_1_03.txt, 01_random_1_04.txt, 02_random_2_00.txt, 02_random_2_01.txt, 02_random_2_02.txt, 02_random_2_03.txt, 02_random_2_04.txt, 02_random_2_05.txt, 02_random_2_06.txt, 02_random_2_07.txt, 02_random_2_08.txt, 02_random_2_09.txt, 03_max_00.txt, 04_min_00.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 41 ms 17240 KiB
00_sample_01.txt AC 41 ms 17192 KiB
00_sample_02.txt AC 42 ms 17372 KiB
01_random_1_00.txt AC 42 ms 17300 KiB
01_random_1_01.txt AC 41 ms 17424 KiB
01_random_1_02.txt AC 41 ms 17260 KiB
01_random_1_03.txt AC 42 ms 17388 KiB
01_random_1_04.txt AC 42 ms 17304 KiB
02_random_2_00.txt AC 41 ms 17016 KiB
02_random_2_01.txt AC 42 ms 17088 KiB
02_random_2_02.txt AC 42 ms 16920 KiB
02_random_2_03.txt AC 42 ms 17288 KiB
02_random_2_04.txt AC 42 ms 17256 KiB
02_random_2_05.txt AC 42 ms 17320 KiB
02_random_2_06.txt AC 41 ms 17204 KiB
02_random_2_07.txt AC 41 ms 16900 KiB
02_random_2_08.txt AC 42 ms 17200 KiB
02_random_2_09.txt AC 42 ms 17412 KiB
03_max_00.txt AC 41 ms 17232 KiB
04_min_00.txt AC 41 ms 17272 KiB