結果

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

ソースコード

diff #

#!/usr/bin/ruby
def perform(n,f)
	d=1
	d+=1 while 10**d<=n
	r=0
	(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)
	}
	r+=(n-2*10**(d-1)-2+10)/10 if n/10**(d-1)>=2
	p r+(f&&n/10**(d-1)==2&&n%10==1 ? 1 : 0)
end
a,b=gets.split.map(&:to_i)
p perform(b,false)-perform(a-1,true)+(a==1&&b>1 ? 1 : 0)
0