prompt string | response string |
|---|---|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;
@SuppressWarnings("unchecked")
public class P792B {
public void run() throws Exception {
int n = nextInt(), k = nextInt();
List<Integer> pi = new ArrayList();
for (int i = 1; i <= n; pi.add(i), i++);
int i = 0;
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int n, k;
int a[110];
int ans[110];
bool use[110];
int main() {
cin >> n >> k;
for (int i = 0; i < k; i++) cin >> a[i];
int cur = 0;
for (int i = 0; i < k; i++) {
int lea = a[i] % (n - i);
for (int j = 0; j < lea; j++) {
if (++cur >= n) cur = 0;
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) a[i] = i + 1;
int v = 0;
for (int x, i = 0; i < k; i++) {
cin >> x;
v += x;
v %= n;
cout << a[v] << " ";
a.erase(a.begin() + v);
n--, v = v % n;
}
ret... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | (n, k) = map(int, input().split())
lst = [int(x) for x in input().split()]
a = [int(x) for x in range(n)]
t = 0
for x in range(k):
t += lst[x]
t %= n - x
print(a[t] + 1, end = ' ')
a = a[:t] + a[t + 1:]
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> rhyme;
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) rhyme.push_back(i);
int circular = 0;
for (int j = 0; j < k; j++) {
int m;
cin >> m;
circular = (circular + m) % n;
cout << rhyme[circular] << " ";
n--;
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n = int(input().split()[0])
a = list(map(int, input().split()))
ch = list(range(1, n + 1))
leader = ch[0]
for ai in a:
out = (ch.index(leader) + ai) % len(ch)
leader = ch[(out + 1) % len(ch)]
print("{} ".format(ch[out]), end='')
del ch[out]
if len(ch) == 0:
break
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | res = ''
ved = 0
ost = 0
(n,k) = map(int,input().split())
s = input().split()
al = [int(c) for c in s]
kl = [c for c in range(n)]
for i in range(k):
ost = al[i] % len(kl)
if ved + ost > len(kl) - 1:
ved = ost - (len(kl) - ved)
else:
ved = ved + ost
res = res + str(kl[ved] + 1) + ' '
kl.remove(kl[ved])
if ved ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | kids_n, rounds_n = [int(x) for x in input().split(' ')]
rounds = [int(x) for x in input().split(' ')]
kids = [x+1 for x in range(kids_n)]
leader = 0
for i in range(rounds_n):
eliminated_index = (leader + rounds[i]) % kids_n
if eliminated_index == kids_n - 1:
leader = 0
else:
leader = eliminated_index
elimin... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.*;
import java.util.ArrayList;
import java.util.StringTokenizer;
/**
* Created by WiNDWAY on 4/3/17.
*/
public class Codeforces_Educational_round_18_CountingOutRhyme {
public static void main(String[] args) {
FScanner input = new FScanner();
out = new PrintWriter(new BufferedOutp... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n,k = map(int,raw_input().split())
ar = map(int,raw_input().split())
ind = 0
nm = [i for i in range(1,n+1)]
ans = []
for i in ar:
i1 = (i+ind)%n
ans.append(nm[i1])
nm.pop(i1)
ind = (i1)%(n-1)
n = n-1
print " ".join(str(i) for i in ans)
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k = map(int, input().split())
A = list(map(int, input().split()))
kids = list(range(1, n+1))
next = 0
res = []
for a in A:
n = len(kids)
lose = (next + a) % n
next = lose % n
res.append(kids.pop(lose))
print(*res) |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... |
import java.io.*;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class Main{
public static void main(String[] args)throws IOException {
FastReader sc = new FastReader();
OutputStream output = System.out;
PrintWriter out = new PrintWriter(output);
//InputStream... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.regex.Pattern;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;
/**
* Built using CHelpe... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int a[110];
int n, k;
void Do(int x, vector<int> v) {
if (x == k) return;
int n = v.size();
int t = a[x] % n;
cout << v[t] << " ";
vector<int> w;
for (int i = 1; i < n; i++) {
w.push_back(v[(t + i) % n]);
}
Do(x + 1, w);
}
void solve() {
cin >> n >> k;... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.util.Scanner;
public class CountingoutRhyme {
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
StringBuilder sb = new StringBuilder();
int location = 0;
boolean arr[] = new boolean[n];
for (int i = 0; i <... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int n, m, d[110], tot, iter;
bool used[110];
int main() {
memset(used, false, sizeof(used));
scanf("%d%d", &n, &m);
for (int i = 0; i < m; i++) scanf("%d", &d[i]);
tot = n;
iter = 1;
for (int i = 0; i < m; i++) {
int dis = d[i] % tot;
for (int i = 0; i <... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.util.*;
import java.io.*;
public class CountingoutRhyme {
/************************ SOLUTION STARTS HERE ***********************/
private static void solve(FastScanner s1, PrintWriter out){
int N = s1.nextInt();
int K = s1.nextInt();
int arr[] = s1.nextIntArray(K);
ArrayList<Integer> ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, x = 0, p;
cin >> n >> k;
long long a[k];
vector<int> v;
for (int i = 0; i < n; i++) v.push_back(i + 1);
for (int i = 0; i < k; i++) cin >> a[i];
for (int i = 0; i < k; i++) {
p = ((a[i] + x) % (n - i));
x = p;
cout << v[x] <<... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n,k = map(int,input().split())
arr = list(map(int,input().split()))
l = [x for x in range(1,n+1)]
cl = 0
for i in range(k):
x = arr[i]
if(x<=len(l)-cl-1):
if(cl+x!=len(l)-1):
print(l[cl+x],end=' ')
del l[cl+x]
cl = cl+x
else:
print(l[cl+x],end=' ')... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Sc... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.util.*;
import java.util.Scanner;
import java.io.*;
import javax.lang.model.util.ElementScanner6;
import static java.lang.System.out;
public class B792
{
public static void main(String args[])
{
FastReader in=new FastReader();
PrintWriter pr = new PrintWriter(new Buff... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int k, n;
cin >> k >> n;
vector<int> cc;
int leaderpos = 0;
for (int i = 1; i <= k; i++) {
cc.push_back(i);
}
vector<int> ques;
for (int i = 0; i < n; i++) {
int ans = 0;
int aa;
cin >> aa;
int cnt = (aa + leaderpos) % cc.siz... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | //package codeforces;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Strin... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
const double INF = 1e12;
const double eps = 1e-9;
int n, k;
int a[100];
list<int> l;
list<int>::iterator it;
int shift(int x) {
int sz = l.size();
x %= sz;
for (int i = 0; i < x; i++) {
it++;
if (it == l.end()) it = l.begin();
}
int... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 5;
const int inf = 1e9 + 5;
int a[105];
queue<int> q;
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
q.push(i);
}
int now = n;
for (int i = 0; i < m; i++) {
in... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
const int Max = 1e6;
int n, k;
vector<int> b;
int a[Max];
int leader, x;
int main() {
cin >> n >> k;
for (int i = 1; i <= k; i++) cin >> a[i];
for (int i = 0; i < n; i++) b.push_back(i + 1);
for (int i = 1; i <= k; i++) {
x = leader + (a[i]);
x %= b.size();
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | l=input().split()
n=int(l[0])
k=int(l[1])
done=[0 for i in range(n)]
count=0
posn=0
l=input().split()
li=[int(i) for i in l]
l=[]
for i in range(n):
l.append(i)
for i in range(k):
posn+=1
posn%=len(l)
li[i]-=1
posn=posn+(li[i]%(len(l)))
posn%=len(l)
done[l[posn]]=1
print(l[posn]+1,end=" ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
bool arr[105];
int main() {
int n, hh;
cin >> n >> hh;
int led = 1;
for (int i = 0; i < hh; i++) {
int x;
cin >> x;
int sim = x % (n - i);
int cnt = 0;
int j;
for (j = led;; j++) {
if (cnt == sim) break;
if (arr[j] == 0 && j != le... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... |
n, k = map(int, input().split())
a = list(map(int, input().split()))
l = list(range(1, n + 1))
ans = []
leader = 0
for i in range(k):
nu = a[i] % len(l)
pos = (leader + nu) % len(l)
if pos == len(l) - 1:
leader = 0
else:
leader = pos
ans.append(l.pop(pos))
print(*ans)
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Ziklon
*/
public class Main
{
public stati... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n,k=map(int,raw_input().split())
nl=[x for x in range(1,n+1)]
a=map(int,raw_input().split())
l=0
for i in range(len(a)):
step=a[i]
r=step%len(nl)
if l+r > len(nl)-1 :
pos = l+r-len(nl)
if pos==len(nl)-1:
l=0
else:
l=pos
else:
pos=l+r
l=po... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int n, k;
int a[111];
int vst[111];
int main() {
cin >> n >> k;
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
int cur = 0;
int nbr = n;
int j = 0;
while (k--) {
int r = a[j++] % nbr;
r++;
nbr--;
int e;
for (int i = cur; r; i = (i + 1) % n) ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
template <class T, class S>
ostream& operator<<(ostream& os, const pair<T, S>& v) {
return os << "(" << v.first << ", " << v.second << ")";
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
os << "[";
for (int i = int(0); i <= int((static_cas... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
vector<int> l;
int main() {
int n, k;
cin >> n >> k;
for (int i = 0; i < n; i++) l.push_back(i + 1);
int now = 0;
while (k--) {
int x;
cin >> x;
int y = (now + x) % l.size();
cout << l[y];
now = y;
if (k) cout << " ";
l.erase(l.begin() ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, leader = 1;
cin >> n >> k;
vector<int> v;
int a[k];
for (int i = 1; i <= n; i++) {
v.push_back(i);
}
for (int i = 0; i < k; i++) {
cin >> a[i];
}
for (int i = 0; i < k; i++) {
int out = (leader + a[i]) % v.size();
if ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | ########################
#By Nour Alhadi Mahmoud#
########################
fl = raw_input().split()
n = int(fl[0])
k = int(fl[1])
sl = raw_input().split()
a = []
for i in sl:
a.append(int(i))
fuck = []
for i in range(1,n+1):
fuck.append(i)
leader = 0
for i in range(k):
mv = (a[i] + leader) % (n-i)
leader = (mv)... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
size_t n, k, left;
std::vector<bool> kids;
size_t next(size_t current) {
current = (current % kids.size());
do {
current = (current + 1) % kids.size();
} while (!kids[current]);
return current;
}
int main() {
std::cin >> n >> k;
left = n;
kids.resize(n, true);
std::vector<in... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import math
n,k = map(int, raw_input().split())
a = map(int, raw_input().split())
b = [1] * n
for i in xrange(0,n):
b[i] = i+1
ans = ""
c = 0
for i in xrange(0,k):
l = (a[i]+c) % n
ans += str(b[l]) + " "
for j in xrange(l,n-1):
b[j] = b[j+1]
c = l
n -= 1
print ans
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n,k = map(int, input().split())
a = list(map(int, input().split()))
L = [ i for i in range(1,n+1) ]
ldr = 0
for x in a:
ldr = (ldr + x)% len(L)
print(L[ldr], end = ' ')
L.pop(ldr)
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k = map(int, (input().split()))
arr = list(map(int, input().split()))
nums = list(range(1, n+1))
leader = 0
elims = []
for i in range(k):
elim = (leader + arr[i]) % n
elims.append(nums.pop(elim))
n -= 1
leader = elim
print(*elims)
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | s1 = raw_input()
s2 = raw_input()
n, k = (int(x) for x in s1.split())
k = [int(x) for x in s2.split()]
p = range(1, n+1)
outs = []
c = 0
for x in k:
i = (x + c) % len(p)
c = i
outs.append(p.pop(i))
print ' '.join([str(x) for x in outs]).strip() |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import math
import os
import random
import re
import sys
def mindist(n, k, list):
player = [i for i in range(1,n+1)]
capo = 0
rem = n
result = ""
for step in range(k):
puntato = (capo + list[step]) % rem
capo = puntato
result += str(player[puntato]) + " "
player.remo... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N], nxt[N], pre[N];
int n, k;
bool Erase[N];
int main() {
scanf("%d%d", &n, &k);
for (int i = 1; i <= k; ++i) scanf("%d", &a[i]);
for (int i = 0; i < n; ++i) {
nxt[i] = (i + 1) % n;
pre[i] = (i - 1 + n) % n;
}
int leader = 0, curN ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.InputMismatchException;
public class E {
public static void main(String[] args) {
FastScannerE sc = new FastScannerE(System.in);
int N = sc.nextInt();
int K = sc.nextInt();
StringBuilder sb = new StringBuilder()... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.*;
import java.util.*;
public class Main {
void solve() throws IOException {
int n = ni(), k = ni();
int[] a = nia(k);
boolean[] children = new boolean[n];
Arrays.fill(children, true);
int idx = 0;
for (int i = 0; i < k; i++) {
int m = a... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k = [int(x) for x in input().split(' ')]
steps = [int(x) for x in input().split(' ')]
circle = list(range(n))
def next_index(i, steps, circle):
length = len(circle)
return (i + steps[0]) % length
index = 0
while len(steps) > 0:
# print(index, steps, circle)
index = next_index(index, steps, circle... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n , k = map(int, input().split())
arr = [i for i in range(1,n+1)]
arg_k = list(map(int, input().split()))
v = 0
for i in arg_k:
l = len(arr)
d = (i + v) % l
print(arr.pop(d))
v = d % len(arr)
#print(arr, v)
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k=map(int, input().split())
l=input()
a=[int(i) for i in l.split()]
m=list(range(1,n+1))
l=""
b=0
d=len(m)
for i in a:
if m[(i+b)%d]==m[len(m)-1]:
l+="{} ".format(m[(i+b)%d])
m.remove(m[(i+b)%d])
b=0
else:
l+="{} ".format(m[(i+b)%d])
m.remove(m[(i+b)%d])
b=m.in... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n,k = map(int,raw_input().split())
nums = list(map(int,raw_input().split()))
arr = [x+1 for x in range(n)]
ans = []
cur = 0
for i in range(k):
nxt = (cur+nums[i])%len(arr)
ans.append(arr.pop(nxt))
cur = nxt
print " ".join([str(x) for x in ans]) |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... |
import java.io.*;
import java.util.*;
import java.lang.Math;
import java.math.BigInteger;
public class ProblemsA {
public static void main(String[] args) throws IOException {
new ProblemsA().run();
}
BufferedReader in;
PrintWriter out;
StringTokenizer tok;
static final boolean ONLINE_JUDGE = System.getProp... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | /*
_oo0oo_
o8888888o
88" . "88
(| -_- |)
0\ = /0
___/`---'\___
.' \\| |// '.
/ \\||| : |||// \
/ _||||| -:- |||||- \
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.util.*;
import java.io.*;
public class CountingOutRhyme {
public static InputReader in;
public static PrintWriter out;
public static final int myMotivation = 0;
public static final int MOD = (int) (1e9 + 7);
public static void main(String[] args) {
in = new InputReader(System.in);
o... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.util.*;
import java.io.*;
public class Solution1 {
private void solve() throws IOException {
int n = in.nextInt();
int k = in.nextInt();
List<Integer> nums = new ArrayList<>();
for (int i = 0; i < n; i++) {
nums.add(i + 1);
}
int[] turns = ne... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* Created by quach on 26/5/2017.
*/
public class B {
private int findNext(int[] players, int num) {
int next = (num + 1) % players.length;
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | from __future__ import print_function
n,k=map(int,raw_input().split())
l=map(int,raw_input().split())
a=[i for i in range(n)]
j=0
for i in range(k):
d=(j+l[i])%len(a);
print(a[d]+1,end=' ')
del a[d]
j=d%(len(a)+1) |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import math
n,k= map(int,input().split())
a= list(map(int,input().split()))
l1=[x for x in range(1,n+1)]
j=0
for i in a:
k-=1
j=(j+i)%n
if k!=0:
print(l1[j],end=' ')
else:
print (l1[j],end='')
n-=1
l1.pop(j)
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int a[110];
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) cin >> a[i];
vector<int> v;
for (int i = 1; i <= n; i++) v.push_back(i);
int lea = 0;
for (int i = 0; i < m; i++) {
lea = (lea + a[i]) % v.size();
cout << v[lea] << " ";
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
const long long inf = 2e9;
const long long md = 1e9 + 7;
const long long P = 27;
long long n, k, x, lst;
vector<int> v;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
;
cin >> n >> k;
for (int i = 1; i <= n; i++) v.push_back(i);
for (i... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | inp1 = input().split()
n=int(inp1[0])
k=int(inp1[1])
koh_lanta = list(range(1,n+1))
liste_elimination = input().split()
lead=0
eliminated = []
for i in range(k):
lead = (lead + int(liste_elimination[i]))%(n-i)
eliminated.append(koh_lanta.pop(int(lead)))
print(*eliminated)
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
void eliminate(long long);
deque<long long> circle;
deque<long long> elimi;
int main() {
long long n, k;
cin >> n >> k;
for (int i = 0; i < n; i++) {
circle.push_back(i + 1);
}
long long cir_size = circle.size();
for (int i = 0; i < k; i++) {
long long t... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | from collections import deque
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
d=deque([i for i in range(1,n+1)])
res=[]
for i in range(k):
d.rotate(-(a[i]))
x=d.popleft()
res.append(x)
print(*res)
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 110;
int a[MAXN];
int main(void) {
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
a[i] = i;
}
int cnt = 1;
while (k--) {
int x;
cin >> x;
cnt += x;
cnt %= n;
if (cnt == 0) {
cnt += n;
}
cout << a[cn... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932384626433;
const int mod = 1000000007;
const long long inf = 3e18;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long n, k;
cin >> n >> k;
vector<long long> a(k), v;
for (long long i = 0; i < k... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long n, k;
cin >> n >> k;
long long a[k + 1];
for (long long i = 1; i <= k; ++i) cin >> a[i];
long long now = 1;
set<long long> out;
for (long long i = 1; i <= k; ++i) {
long long p = now;
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n,k=map(int, raw_input().split())
a=map(int, raw_input().split())
c = [i+1 for i in range(n)]
lead = 0
for i in a:
i %= len(c)
rem = (lead + i) % len(c)
print c[rem],
c.remove(c[rem])
lead = rem%len(c) |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.util.*;
public class ProblemB {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
int k = sc.nextInt();
long rot[] = new long[k];
for(int i=0;i<k;i++){
rot[i] = sc.nextLong();
}
ArrayList<Lon... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | '''input
7 5
10 4 11 4 1
'''
n, k = map(int, input().split())
a = list(map(int, input().split()))
l = list(range(1,n+1))
leader = 0
for x in a:
lx = (leader+x) % n
# print(lx)
print(l[lx], end = " ")
del l[lx]
n -= 1
leader = lx % n
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.util.ArrayList;
import java.util.Scanner;
public class b {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int k = in.nextInt();
ArrayList<Integer> ps = new ArrayList<>();
for(int i=0;i<n;i++)
ps.add(i);
int ptr = 0;
for(int i=0;i<k;i++)... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | def findout(A,x):
ans=A[x%len(A)]
new_A=A[x%len(A)+1:]+A[:x%len(A)]
return new_A,ans
Ans=[]
n,k=list(map(int,input().strip().split(' ')))
change=list(map(int,input().strip().split(' ')))
A=[i+1 for i in range(n)]
for x in change:
A,ans=findout(A,x)
Ans+=[ans]
Ans=[str(x) for x in Ans]
print(" ".join... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, i, tmp;
int curr = 0;
cin >> n >> k;
vector<int> vect(n);
for (i = 0; i < n; ++i) vect[i] = i + 1;
for (i = 0; i < k; ++i) {
cin >> tmp;
curr = (curr + tmp % n) % n;
cout << vect[curr] << ' ';
vect.erase(vect.begin() + curr... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.*;
import java.util.*;
import java.math.*;
public class Edu18Q2
{
public static void main(String[] args) throws IOException
{
FastScanner obj = new FastScanner();
out = new PrintWriter(new BufferedOutputStream(System.out));
int n = obj.nextInt();
int k = obj.next... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | def geti():
return map(int, input().split())
n, k = geti()
a = list(geti())
xk = [i+1 for i in range(n)]
t = 1
b = []
x = 0
for i in range(k):
x = ((x + a[i]) % len(xk))
b.append(xk[x])
xk.remove(xk[x])
for i in b:
print(i,end=' ')
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | /*
Author - Ayub Subhaniya
Institute - DAI-ICT
*/
import java.io.*;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
public class Codeforce392 {
static FastScanner in=new FastScanner();
static OutputWriter out=new OutputWriter(System.out);
public static void main(String[] args) {... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n,k = map(int,input().split())
a = [int(x) for x in input().split()]
v = [i for i in range(1,n+1)]
val = 0
ans = ""
for i in a:
i %= len(v)
val += i
if val>=len(v): val -= len(v)
ans += str(v[val]) + ' '
del v[val]
print(ans)
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
public class B {
public static void main(String[] args... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
long long n, k;
deque<long long> d;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
for (long long i = 1; i <= n; i++) d.push_back(i);
for (long long i = 0; i < k; i++) {
long long a;
cin >> a;
a %= d.size();
while (a--) {
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.*;
import java.util.*;
public final class counting_out
{
static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
static FastScanner sc=new FastScanner(br);
static PrintWriter out=new PrintWriter(System.out);
static Random rnd=new Random();
public static void main(St... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n,k = map(int, raw_input().strip().split())
kmap = map(int, raw_input().strip().split())
start = 0
arr = range(1,n+1)
for i in xrange(k):
start = (start + kmap[i]) % n
print arr.pop(start),
n -= 1 |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;
int main() {
int n, k;
cin >> n >> k;
vector<long long> a(k + 1);
for (int i = 1; i <= k; i++) cin >> a[i];
vector<bool> is_alive(n + 1, true);
int alive = n;
int leader = 1;
for (int i = 1; i <= k; i++) ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.util.Scanner;
import java.util.Vector;
public class CountingOutRhyme {
public static void main(String[] args){
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int k = s.nextInt();
Vector<Integer> children = new Vector<Integer>();
for (int i = 0; i < n; i++){
children.add(i+1);
}... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import sys
n,k = map(int,raw_input().split())
c = map(int,raw_input().split())
i = 0
l = 1
x = range(1,n+1)
while(i<k):
l = (l-1+c[i])%len(x)
y = l + 1
print x[l],
del(x[l])
l = y
i = i + 1
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k = map(int, input().split())
aa = [int(x) for x in input().split()]
nxt = [(i + 1) % n for i in range(n)]
prv = [(i - 1 + n) % n for i in range(n)]
cur = 0
for z in range(k):
a = aa[z]
a %= n
for i in range(a):
cur = nxt[cur]
nxt[prv[cur]] = nxt[cur]
prv[nxt[cur]] = prv[cur]
print(... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | first = raw_input().split()
n, k = int(first[0]), int(first[1])
a = [int(num) for num in raw_input().split()]
o = [num + 1 for num in range(n)]
lead = 0
ans = []
for ai in a:
next = (lead + ai) % n
lead = (next + 1) % n
ans.append(o[next])
del o[next]
if lead != 0:
lead -= 1
n -= 1
prin... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n,k = input().split()
n = int(n)
k = int(k)
a = list(map(int,input().split()))
b = []
for i in range(n):
b.append(i+1)
ptr = 1
for i in range(k):
temp = (ptr + a[i])%n
print(b[temp-1],end=" ")
b.pop(temp-1)
ptr = temp
if(temp == 0):
ptr = 1
n-=1
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = [0]*k
p = list(range(1, n+1))
i = 0
for j in range(k):
i = (i + a[j]) % len(p)
ans[j] = p[i]
p.pop(i)
i %= len(p)
print(*ans)
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, _ = [int(i) for i in input().strip().split(' ')]
ak = [int(i) for i in input().strip().split(' ')]
people = list(range(1, n + 1))
current = 0
leaved = []
for k in ak:
pos = ((current + k) % len(people))
leave = people.pop(pos)
leaved.append(leave)
if pos >= len(people):
current = 0
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k = [int(x) for x in input().split(' ')]
steps = [int(x) for x in input().split(' ')]
steps.reverse() # to use list.pop()
circle = list(range(n))
def next_index(i, step, circle):
length = len(circle)
return (i + step) % length
index = 0
for i in range(len(steps)):
# print(index, steps, circle)
i... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | i = 0
def someFunc():
global i
i += 1
return i
class Human:
def __init__(self, value, kum):
self.value = value
self.kum = kum
n, k = map(int, input().split())
aa = list(map(int, input().split()))
a = list(range(1, n + 1))
for i in aa:
y = i % len(a)
print(a[y],end=' ')
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
deque<int> d;
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) d.push_back(i);
for (int i = 0; i < k; i++) {
int a;
cin >> a;
a = a % d.size();
while (a--) {
d.push_back(d.front());
d.pop_front();
}
int cnt = d... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | var params = readline().split(" ").map(function convert(value) {return +value; });
var n = params[0];
var k = params[1];
var input = readline().split(" ").map(function convert(value) {return +value;});
var children = [];
var answer = [];
var prevChildIndex = 0;
for (var i = 1; i <= n; i++)
children.push(i);
for (var... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | //package ques3;
import java.util.*;
import java.io.*;
import java.lang.Math.*;
public class MainA {
public static int mod = 20000;
public static long[] val;
public static long[] arr;
static int max = (int) 1e9 + 7;
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
Print... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int a[105], vis[105];
vector<int> p, c;
int main() {
int n, k, now = 1;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
cin >> a[i];
}
p.push_back(0);
for (int i = 1; i <= n; i++) {
p.push_back(i);
}
int len = n;
for (int i = 1; i <= k; i++) {
ve... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.*;
import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
PrintWriter pw=new PrintWriter(System.out);
while(sc.hasNext()){
int n=sc.nextInt();
int k=sc.nextInt();
int[]jl=new int... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k = (int(x) for x in input().split())
a = [i + 1 for i in range(n)]
k = [int(x) for x in input().split()]
cur = 0
for x in k:
cur += x
cur %= n
print(a[cur], end=' ')
del(a[cur])
n -= 1
cur %= n
print()
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n,k=map(int,input().split())
list_k=list(map(int,input().split()))
list_child=[i for i in range(n)]
count_from=1
for i in range(k):
eliminate=(list_k[i]+count_from-1)%len(list_child)
print(list_child.pop(eliminate)+1,end=" ")
count_from=(eliminate+2)%len(list_child)
count_from-=1 |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... |
import java.util.*;
import java.io.*;
/**
*
* @author umang
*/
public class Problem {
public static int mod = (int) (1e9+7);
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
int... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | //package cc.rengu.algorithm;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
public class Main {
/**
* 1 2 3 4 5 6 7
* 5
* 10 4 11 4 1
* -----------
* 1 2 3 4 5 6 7
* 1 2 3 5 6 7 ----4 out 5 leader
* 1 3 5 6 7 ----2 out ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | from collections import deque
def rhymes(n,a):
children = deque(range(1,n+1))
result = []
for step in a:
children.rotate(-step)
result.append(children.popleft())
return result
def main():
n, k = map(int, input().strip().split())
a = tuple(map(int, input().strip().split()))
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import sys
n,k = map(int,input().split())
arr = list(map(int,input().split()))
num =[]
for i in range(n):
num.append(i+1)
cnt = pos = elliminate = 0
res = []
for j in range(k):
cnt = arr[j] % n
if(elliminate + cnt < n):
elliminate = elliminate+cnt
else:
elliminate = cnt - (n-1-ellimina... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.