Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e679016

Browse files
Created savethePrisoner.js
1 parent 0427d20 commit e679016

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

‎Implementation/savethePrisoner.js‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
function saveThePrisoner(n, m, s){
2+
// Complete this function
3+
var id;
4+
id= s+(m-1);
5+
if(id>n){
6+
var rem= id%n;
7+
if(rem==0){
8+
rem=n;
9+
}
10+
return rem;
11+
}
12+
return id;
13+
}
14+
15+
function main() {
16+
var t = parseInt(readLine());
17+
for(var a0 = 0; a0 < t; a0++){
18+
var n_temp = readLine().split(' ');
19+
var n = parseInt(n_temp[0]);
20+
var m = parseInt(n_temp[1]);
21+
var s = parseInt(n_temp[2]);
22+
var result = saveThePrisoner(n, m, s);
23+
process.stdout.write(""+result+"\n");
24+
}
25+
26+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /