結果
| 問題 |
No.1747 Many Formulae 2
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2022-01-22 18:47:31 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,073 bytes |
| コンパイル時間 | 279 ms |
| コンパイル使用メモリ | 7,076 KB |
| 実行使用メモリ | 11,756 KB |
| 最終ジャッジ日時 | 2024-11-27 18:38:21 |
| 合計ジャッジ時間 | 3,264 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 1 |
ソースコード
local mce, mfl, msq, mmi, mma, mab = math.ceil, math.floor, math.sqrt, math.min, math.max, math.abs
local bls, brs = bit.lshift, bit.rshift
local function getprimes(x)
local primes = {}
local allnums = {}
for i = 1, x do allnums[i] = true end
for i = 2, x do
if allnums[i] then
table.insert(primes, i)
local lim = mfl(x / i)
for j = 2, lim do
allnums[j * i] = false
end
end
end
return primes
end
local primes = getprimes(1000000)
local function isprime(x)
for i = 1, #primes do
if x == primes[i] then return true end
if x % primes[i] == 0 then return false end
end
return true
end
local s = io.read()
local n = #s
local t = {}
for i = 1, n do
t[i] = s:byte(i) - 48
end
local ret = 0
local tot = bls(1, n - 1)
for i = 0, tot - 1 do
local v = 0
local c = t[1]
local ti = i
for j = 2, n do
if ti % 2 == 0 then
c = c * 10 + t[j]
else
v = v + c
c = t[j]
end
ti = brs(ti, 1)
end
v = v + c
-- print(v)
if isprime(v) then
ret = ret + 1
end
end
print(ret)