結果

問題 No.319 happy b1rthday 2 me
ユーザー cielciel
提出日時 2015-12-13 03:13:50
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 449 bytes
コンパイル時間 55 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-09-15 11:02:51
合計ジャッジ時間 4,041 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21 WA * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/usr/bin/ruby
def perform(n,f)
	d=1
	d+=1 while 10**d<=n
	r=f&&(n+1)/10**(d-1)==2&&n%10==1 ? 1 : 0
	return r if n<2
	return r+1 if n<12

	(d-2).downto(0){|i|
		a,x=n.divmod(10**(i+2))
		b,c=x.divmod(10**(i+0))
		if b>12
			a+=1
			c=0
		elsif b<12
			c=0
		else
			c+=1
		end
		r+=a*10**i+c
	}
	1.upto(d-1){|i|
		r+=i<3 ? 1 : 10**(i-2)
	}
	x=n-2*10**(d-1)-2+10
	r+=x/10 if x>0
	r
end
a,b=gets.split.map(&:to_i)
p perform(b,false)-perform(a-1,true)
0