R, (削除) 301 (削除ここまで) 299 bytes
Explanation.
Look up the index of the mass sorted atomic number in a UTF8 encoded hash string s. The hash is taken by multiplying the vector c(3,100) by the ASCII byte number of the characters of the element name, taking the sum, and taking that mod 366.
Encode the masses of the elements as a UTF8 encoded string of differences, packing 2 differences into each byte as 9*d1 + d2 where d1 is the difference of the nth element and d2 is the successive mass difference of the n+50th element. Then to retrieve the mass, take the cumulative sum of the differences plus 1 (the mass of H). This is shorter than a quadratic formula.
function(x)sum(c(o%%9,o%/%9)[1:match(sum(c(3,100)*!x)%%366,!"`Dr2ÒĹŜUĀV4ě1⁄4'ùċJÿû>Łx1⁄2ĢAŝeüė¤įńşĎê Ŧ÷L·ïč§Çhtţ.5ĦŠ ©ÃŋaâŐą¬1Ø ̈F±bđ·ČHTŨSĊĈ@Õ:&XősäyĜũ")])
"!"=utf8ToInt
o=!"0%..%$%%
p
&00(1"
- 2.7k
- 12
- 15