From 1f9cdd4cce664439625f13da1baf894190b7e9a6 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Mon, 17 Feb 2020 20:29:47 +0700 Subject: Thank you Corona for giving me some time to do this --- codechef/nochange.lua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 codechef/nochange.lua (limited to 'codechef/nochange.lua') diff --git a/codechef/nochange.lua b/codechef/nochange.lua new file mode 100755 index 0000000..818959c --- /dev/null +++ b/codechef/nochange.lua @@ -0,0 +1,36 @@ +#!/usr/bin/env lua +local read = io.read +local print = print +local table = {concat = table.concat, insert = table.insert} + +for t = 1, read('*n') do + local n, p = read('*n', '*n') + local d = {} + for i = 1, n do table.insert(d, read('*n')) end + + local unanswered, previous = true, 1 + for k, v in ipairs(d) do + if p % v ~= 0 then + local c = {} + for i = 1, k-1 do table.insert(c, 0) end + table.insert(c, p//v+1) + for i = k+1, n do table.insert(c, 0) end + print(('YES %s'):format(table.concat(c, ' '))) + unanswered = false + break + end + + if v % previous ~= 0 then + local c = {} + for i = 1, k-2 do table.insert(c, 0) end + table.insert(c, v//previous+1) + table.insert(c, p//v-1) + for i = k+1, n do table.insert(c, 0) end + print(('YES %s'):format(table.concat(c, ' '))) + unanswered = false + break + end + previous = v + end + if unanswered then print('NO') end +end -- cgit 1.4.1