1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | t = Integer(gets) while t > 0 a4 = [] a7 = [] n = Integer(gets) i = a4.length + 1 if n > a4.length while i <= n a4 << i.to_s.count("4") a7 << i.to_s.count("7") i = i + 1 end end l=1 count = 0 while l <= n i = l r = l sum4 = 0 sum7 =0 while r <= n while i <= r sum4 = sum4 + a4[i].to_i sum7 = sum7 + a7[i].to_i if(sum4 == sum7) count = count + 1 end i = i + 1 end r = r + 1 end l = l + 1 print "#{count}\n" end t = t - 1 end |
dCA9IEludGVnZXIoZ2V0cykKd2hpbGUgdCA+IDAKYTQgPSBbXQphNyA9IFtdCm4gPSBJbnRlZ2VyKGdldHMpCmkgPSBhNC5sZW5ndGggKyAxCmlmIG4gPiBhNC5sZW5ndGgKd2hpbGUgaSA8PSBuCmE0IDw8IGkudG9fcy5jb3VudCgiNCIpCmE3IDw8IGkudG9fcy5jb3VudCgiNyIpCgppID0gaSArIDEKZW5kCmVuZApsPTEKY291bnQgPSAwCndoaWxlIGwgPD0gbgppID0gbApyID0gbApzdW00ID0gMApzdW03ID0wCndoaWxlIHIgPD0gbgp3aGlsZSBpIDw9IHIKc3VtNCA9IHN1bTQgKyBhNFtpXS50b19pCnN1bTcgPSBzdW03ICsgYTdbaV0udG9faQppZihzdW00ID09IHN1bTcpCmNvdW50ID0gY291bnQgKyAxCmVuZAppID0gaSArIDEKZW5kCnIgPSByICsgMQplbmQKbCA9IGwgKyAxCnByaW50ICIje2NvdW50fVxuIgplbmQKCnQgPSB0IC0gMQplbmQ=
-
upload with new input
-
result: Success time: 0s memory: 4760 kB returned value: 0
1 3
3 5 6
-
result: Success time: 0.01s memory: 4760 kB returned value: 0
1 10
7 13 18 20 21 21 25 28 30 31



