-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10250.js
39 lines (32 loc) · 909 Bytes
/
10250.js
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
39
const { fork } = require("child_process");
var readline = require("readline");
var r = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let input = [];
r.on("line", function (line) {
input.push(line);
}).on("close", function () {
main(input);
process.exit();
});
function numFormat(variable) {
variable = Number(variable).toString();
if (Number(variable) < 10 && variable.length == 1)
variable = "0" + variable;
return variable;
}
function main(input) {
const [length, ...testCases] = input;
testCases.forEach(testCase => {
const [H, W, N] = testCase.split(' ').map(_ => +_);
const lastNumn = Math.ceil(N / H);
const floor = (N % H) === 0 ? H : N % H
if(H === 1){
console.log(H + numFormat(N))
}else{
console.log(floor + numFormat(lastNumn));
}
});
}