結果
| 問題 |
No.319 happy b1rthday 2 me
|
| ユーザー |
|
| 提出日時 | 2015-12-13 02:51:02 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 445 bytes |
| コンパイル時間 | 147 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 12,416 KB |
| 最終ジャッジ日時 | 2024-09-15 11:00:45 |
| 合計ジャッジ時間 | 4,091 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 WA * 8 |
コンパイルメッセージ
Syntax OK
ソースコード
#!/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
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&&1<b&&b<10 ? 1 : 0)