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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class CountingOutRhyme {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] data = br.readLine... |
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(" ")]
leader = 0
children = [x for x in range(1, n + 1)]
result = []
for s in steps:
next_index = (leader + s) % len(children)
result.append(children[next_index])
del children[next_index]
leader = next_index
print(" ".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 ... | import java.io.*;
import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;
public class Main {
public static void main(String[] args) {
FastScanner sc=new FastScanner();
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 ... | import java.util.ArrayList;
import java.util.Scanner;
public class thr {
public static void main(String[] args) throws java.lang.Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
int voda = 1;
ArrayList<Integer> krug = new ArrayL... |
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 ... | a,b=map(int,input().split())
z=[*range(1,a+1)];p=0
c=list(map(int,input().split()))
for i in range(b,0,-1):p=(p+c.pop(0))%a;print(z.pop(p));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 ... | n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
c = list(range(1, n + 1))
ved = 0
for i in a:
n = i % len(c)
ved = ved + n
if (ved >= len(c)):
ved -= len(c)
print(c[ved], end=" ")
c.pop(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 ... | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
new Main().solve();
}
int inf = 2000000000;
int mod = 1000000007;
double eps = 0.0000000001;
PrintWriter out;
int n;
int m;
ArrayList<Integer>[] g = 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.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.u... |
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(i) for i in input().split()]
passos=[int(i) for i in input().split()]
cri=[]
for i in range(n):
cri.append(i+1)
ini=0
for p in passos:
ini+=p
ini%=len(cri)
print(cri[ini],end =" ")
cri.pop(ini)
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;
vector<int> num;
vector<int> result;
vector<int> List;
int vis[105];
int main() {
int n, k, t;
scanf("%d%d", &n, &k);
for (int i = 0; i < k; i++) {
scanf("%d", &t);
num.push_back(t);
}
for (int i = 1; i <= n; i++) {
vis[i] = 1;
List.push_back(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, k, a[111];
vector<int> v;
int main() {
cin >> n >> k;
for (int i = 0; i < k; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) {
v.push_back(i);
}
int ind = 0;
for (int i = 0; i < k; i++) {
ind %= v.size();
int nxt = (ind + a[i]) % v.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 ... | n, k = map(int, input().split())
a = map(int, input().split())
kids = list(range(n))
leader = 0
out = []
for ai in a:
ai += leader
ai %= n
kid = kids[ai]
kids = kids[:ai] + kids[ai + 1:]
n -= 1
leader = ai % n
out.append(kid + 1)
print(" ".join(map(str, 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 ... | #include <bits/stdc++.h>
using namespace std;
int n, k, a[111];
int main() {
cin >> n >> k;
for (int i = 0; i < k; i++) {
cin >> a[i];
}
vector<int> v;
for (int i = 0; i < n; i++) {
v.push_back(i + 1);
}
int ind = 0, nxt = 0;
for (int i = 0; i < k && v.size(); i++) {
ind %= v.size();
nxt... |
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;
scanf("%d %d", &n, &k);
vector<long long int> v;
vector<long long int>::iterator it;
long long int a[k], i, j, c, t, x;
for (i = 0; i < k; i++) scanf("%lld", &a[i]);
for (i = 1; i <= n; i++) v.push_back(i);
c = 0;
for (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 ... | import java.util.*;
import javafx.util.*;
import java.io.*;
import java.math.*;
public class T1 {
PrintWriter pw = new PrintWriter(System.out);
int a;
void run(){
a = ni();
int k = ni();
ArrayList<Integer> l = new ArrayList<>();
for(int q=0; q<a; q++) l.add(q+1);
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;
vector<int> v;
vector<int> v1;
int main() {
int k, n;
cin >> n >> k;
for (int i = 0; i < k; i++) {
int in;
cin >> in;
v.push_back(in);
}
for (int i = 1; i <= n; i++) v1.push_back(i);
int leader = 0;
for (int i = 0; i < k; i++) {
leader = (leade... |
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;
unsigned int a[100];
int main(int argc, char* argv[]) {
ios_base::sync_with_stdio(false);
unsigned int n, k;
cin >> n >> k;
for (unsigned int i = 1; i <= n; ++i) a[i - 1] = i;
unsigned int v = 0;
for (unsigned int i = 0; i < k; ++i) {
unsigned int ca;
ci... |
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>
int main() {
int n, i, j, k, l, x, a[101], temp[101];
scanf("%d", &n);
for (i = 0; i < 101; i++) a[i] = i + 1;
scanf("%d", &k);
for (i = 0, j = 0; i < k; i++, n--) {
scanf("%d", &x);
if (i != k - 1)
printf("%d ", a[x % n]);
else
printf("%d\n", a[x % n]);
fo... |
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.math.*;
import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args ) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] in = br.readLine().split(" ");
int n = Integer.parseInt(in[0]);
int k = Integer.parseInt(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 main() {
int n, k;
cin >> n >> k;
int a[k + 1];
int leader = 1;
int mov;
int ans;
vector<int> v;
for (int i = 1; i <= n; i++) {
v.push_back(i);
}
for (int i = 1; i <= k; i++) {
cin >> a[i];
if (leader + a[i] > n) {
mov = a[i] - 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, k = map(int, input().split())
data = map(int, input().split())
arr = [i+1 for i in range(n)]
for v in data:
l = len(arr)
i = v % l
print(arr[i], end = " ")
arr = [arr[(i+k) % l] for k in range(1,l)]
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 ... | //package org.javadov.codeforces.contestEducational;
import java.io.*;
import java.util.StringTokenizer;
/**
* Created by asgar on 2/21/17.
*/
public class TaskB {
public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {
int n = in.nextInt();
int k = in.nextInt();... |
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 = 200 + 10;
int a[MAXN];
int b[MAXN];
int main() {
int n, k;
scanf("%d%d", &n, &k);
for (int i = 0; i < k; i++) {
scanf("%d", a + i);
}
for (int i = 1; i <= n; i++) {
if (i == n)
b[i] = 1;
else
b[i] = i + 1;
}
int cur = 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.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
public static void main(String[] args) {
InputReader in = new InputReader();
PrintWriter out = new PrintWriter(System.out);
final long start = System.currentTimeMillis();
new Task1().... |
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 B {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = scan.nextInt(), k = scan.nextInt();
ArrayDeque<Integer> q = new ArrayDeque<>();
for(int i = 0 ; i < k ; i++)
q.offer(scan.nextInt... |
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
#import random
from bisect import bisect_right as rb
from collections import deque
#sys.setrecursionlimit(10**8)
from queue import PriorityQueue
from math import *
input_ = lambda: sys.stdin.readline().strip("\r\n")
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : lis... |
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.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.StringTokenizer;
public class CountingOutRhyme {
public static void main(String[] args) {
out = new PrintWriter... |
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;
deque<int> q;
int n, m, a;
int main() {
cin >> n >> m;
for (int i = 0; i < n; i++) q.push_back(i + 1);
while (m--) {
cin >> a;
a %= q.size();
while (a--) {
q.push_back(q.front());
q.pop_front();
}
cout << q.front() << ' ';
q.pop_fro... |
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.regex.*;
public class vk18
{
public static void main(String[]stp) throws Exception
{
Scanner scan=new Scanner(System.in);
//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//String []s;
int n=scan.nextI... |
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(void) {
long n, k;
cin >> n >> k;
vector<long> a(k);
for (long i = 0; i < k; i++) cin >> a[i];
vector<int> child(n + 1);
for (long i = 0; i < n + 1; i++) child[i] = i;
long leader = 1;
long size = n;
for (long i = 0; i < k; i++) {
long count;
... |
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
raw_input = sys.stdin.readline
n, k = [int(x) for x in raw_input().split()]
l = [int(x) for x in raw_input().split()]
nxt = [(x+1)%n for x in xrange(n)]
prv = [(x-1)%n for x in xrange(n)]
cur_head = 0
#print nxt
#print prv
for i in xrange(k):
acc = l[i]
acc %= n
for _ in xrange(acc):
cur_head = nxt[... |
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 mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
vector<int> g[N];
int a[N], el[N];
int lead = 0, n;
int go(int x) {
int left = 0;
int i;
for (i = 0; i < n; i++) left += el[i] == 0;
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 ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int id[400], n, k;
while (~scanf("%d%d", &n, &k)) {
int x = 0, num;
for (int i = 1; i <= n; ++i) id[i] = i;
for (int i = 1; i <= k; ++i) {
cin >> num;
x += num;
x %= n;
if (i != 1) printf(" ");
printf("%d", id[x + 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() {
int n, k;
cin >> n >> k;
vector<int> data;
for (int i = 1; i <= n; ++i) {
data.push_back(i);
}
int head = 1;
for (int i = 0; i < k; ++i) {
int a;
cin >> a;
head += a;
head %= data.size();
if (head == 0) head = data.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 ... | a , b = map ( int , raw_input () . split () )
c = map ( int , raw_input () . split () )
if 2 <= a <= 100 and 1 <= b <= a - 1 and len (c) == b :
d = [ x+1 for x in xrange (a) ]
i = 0
p = 0
f = []
while b != 0 :
g = c [i] + p
j = g - ( g / a ) * 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 = map(int, input().split()) # n детей, k шагов
lst = []
for i in range(n):
lst.append(i + 1)
klst = list(map(int, input().split()))
index = 0
for i in range(k):
index = (index + klst[i]) % len(lst)
print(lst.pop(index), 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>
#pragma GCC optimize("O3")
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> v;
for (int i = 0; i < n; i++) {
v.push_back(i + 1);
}
int lea = 0;
for (int i = 0; i < m; i++) {
int a;
cin >> a;
lea = (lea + a) % 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 ... | import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Scanner;
import java.util.function.Consumer;
/**
* Created by shalom on 3/27/17.
*/
public class B1 {
public static void main(String[] args) {
Scanner scanner = new Scanner(Sys... |
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 int MOD = 1000000007;
long long int inf = 1e15;
long long int powermod(long long int _a, long long int _b, long long int _m) {
long long int _r = 1;
while (_b) {
if (_b % 2 == 1) _r = (_r * _a) % _m;
_b /= 2;
_a = (_a * _a) % _m;
}
return _r;
}... |
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, pos, x, N;
bool usd[1000];
int main() {
cin >> n >> m;
pos = 1;
N = n;
for (int i = 1; i <= m; i++) {
cin >> x;
x %= N;
for (; x > 0;) {
pos++;
if (pos > n) pos %= n;
if (usd[pos] == 0) x--;
}
usd[pos] = 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 ... | n, k = map(int, raw_input().split(' '))
yy = map(int, raw_input().split(' '))
#print n, k
l = 0
xx = range(1, n+1)
xy = []
for i in yy:
indx = (l + i) % len(xx)
xy.append(xx[indx])
del xx[indx]
l = indx % len(xx)
for x in xy:
print 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=list(map(int,input().split()))
a=list(map(int,input().split()))
leaderidx=0
children=[i for i in range(1,n+1)]
ans=[]
for i in range(k):
mov=a[i]%len(children)
leaderidx=(leaderidx+mov)%len(children)
ans.append(str(children[leaderidx]))
del(children[leaderidx])
print(" ".join(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 ... | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> child;
int n, k;
scanf("%d %d", &n, &k);
int *A = new int[k];
for (int i = 0; i < k; ++i) {
scanf("%d", &A[i]);
}
for (int i = 0; i < n; ++i) {
child.push_back(i + 1);
}
int count = 0;
for (int i = 0; i < k; ++i) {
co... |
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=raw_input().split()
n,k=int(n),int(k)
nums=[]
for i in range(1,n+1):
nums.append(i)
leader=1
inp=raw_input().split()
for i in inp:
n=len(nums)
a=int(i)
x=(a-(n-leader))%n
if x == 0:
print nums[n-1],
del nums[n-1]
leader=1
else:
print nums[x-1],
del nums[x-1]
leader=x
# print nums,leader
|
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 queue
n, k=map(int,input().split())
s=[]
a=[int(cost) for cost in input().split()]
for i in range(1,n+1):
s.append(i)
for i in range(0,k):
b=a[i]%n
print(s[b],"",end='')
temp_arr=[]
for i in range(b+1,n):
temp_arr.append(s[i])
for i in range... |
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()))
lead = 0
people = [i + 1 for i in range(n)]
for d in a:
nex = (lead + d) % len(people)
print(people[nex],end = ' ')
del people[nex]
nex %= n
lead = nex
|
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, i, k, s[105], p, pos = 0;
cin >> n >> k;
for (i = 0; i < n; i++) s[i] = i + 1;
while (k--) {
cin >> p;
pos = (pos + p) % n;
cout << s[pos] << " ";
if (pos == n - 1) {
n--;
pos = 0;
} else {
for (int j = pos; ... |
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 = [i for i in range(1,n+1)]
arr = [int(x) for x in input().split()]
lead = 0;
for i in range(k):
print(lst.pop((lead+arr[i])%n),end=" ")
lead = (lead+arr[i])%n
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 ... | n,k=map(int,input().split())
a=[i for i in range(1,n+1)]
move=[int(i) for i in input().split()]
for m in move:
#print(m)
m%=len(a)
print(a[m],end=' ')
a=a[m+1:]+a[:m] |
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;
int c;
vector<int> v;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
v.push_back(i);
}
for (int i = 0; i < k; i++) {
cin >> c;
c = c % v.size();
rotate(v.begin(), v.begin() + c, v.end());
cout << v[0] << " ";
v.era... |
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 exceed(long long x, long long y, long long m) { return x >= m / y + 1; }
long long n, k;
long long a[105];
vector<long long> vec;
int main(void) {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
for (long long(i) = (1); (i) <= (k); (i)++) cin >> a[i];
for... |
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.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;... |
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 ... | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
//package codeforces.countingoutrhyme;
import java.util.*;
/**
*
* @author Hp
*/
public class CodeforcesCountingoutrhyme {
/**
... |
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() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<int> v(k);
for (long long i = 0; i < k; i++) cin >> v[i];
vector<int> cir(n);
for (long long i = 1; i < n + 1; i++) {
cir[i - 1] = i;
}
int lead = 1;
for (long long 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 inf = (1e9) + 7;
int v[200005];
int eliminated[2000005];
int main() {
int n, k;
cin >> n >> k;
memset(eliminated, 0, sizeof(eliminated));
for (int i = 0; i < k; ++i) {
scanf("%d", v + i);
v[i] %= (n - i);
}
int leader = 0;
for (int 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 ... | import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.PrintStream;
import java.io.IOException;
import java.util.*;
public final class CodeForces792B {
public static void main(final String... args) throws Exception {
exec(new Scanner(new BufferedReader(new InputStreamReader(System... |
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 R792B {
FastScanner in;
PrintWriter out;
void solve() {
int n=in.nextInt(), k=in.nextInt(), c=n, i=n-1;
boolean[]u=new boolean[n];
Arrays.fill(u, true);
while(k-->0) {
int a=c+((in.nextInt()+1) % 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 counting_rhyme {
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int k=sc.nextInt();
int lead=0;
ArrayList<Integer> pos=new ArrayList(n);
for(int i=1;i<=n;i++){
pos.add(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 a[105];
int main() {
vector<int> v;
int i, n, k;
cin >> n >> k;
for (i = 1; i <= n; i++) {
v.push_back(i);
}
for (i = 0; i < k; i++) {
cin >> a[i];
}
int pos = 0;
int j = 0;
while (k--) {
pos = (pos + a[j++]) % v.size();
cout << v[pos... |
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>
void cutout(int a[], int i, int total);
int main() {
int n, k, i, temp, i1;
scanf("%d%d", &n, &k);
int a[n], b[k], c[k];
for (i = 0; i < k; i++) {
scanf("%d", &b[i]);
}
for (i = 0; i < n; i++) {
a[i] = i + 1;
}
temp = 0;
i = 0;
while (i < k) {
temp = b[i] - 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;
const int MAX = 1e2 + 5;
vector<int> v[MAX];
int main() {
int n, k, i, x, pre = 1, n1;
scanf("%d %d", &n, &k);
n1 = n;
bool vis[MAX];
memset(vis, false, sizeof(vis));
for (i = 1; i <= k; i++) {
scanf("%d", &x);
x %= n;
int val = pre;
while (x > 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>
struct node {
int data;
struct node *link;
};
struct node *head, *newnode;
int main() {
int n, k;
long long a, b;
struct node *temp;
head = NULL;
scanf("%d %d", &n, &k);
int i = 1;
while (i <= n) {
newnode = (struct node *)malloc(sizeof(struct node));
newnode->link = 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, k = map(int,input().split())
childs = [i for i in range(1, n +1)]
data = list(map(int,input().split()))
last_start = 0
count = n
for el in data:
a = el % count
print(childs.pop((last_start + a) % count), end = " ")
last_start = (last_start + a) % count
count -= 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 n, k;
bool killed[110];
int a[110];
int main() {
cin >> n >> k;
for (int i = 0; i < k; i++) {
cin >> a[i];
}
int cnt = n;
int now = 0;
for (int i = 0; i < k; i++) {
a[i] %= cnt;
int next = now;
while (a[i]--) {
next++;
if (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 ... | import java.io.*;
import java.util.*;
public final class Main {
public void solve() {
int n = in.nextInt();
int k = in.nextInt();
int[] a = new int[k];
for (int i = 0; i < k; i++) {
a[i] = in.nextInt();
}
LinkedList<Integer> ll1 = new LinkedList<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 ... | import java.io.*;
import java.util.*;
public class CountingOutRhyme {
static class Scan {
private byte[] buf=new byte[1024];
private int index;
private InputStream in;
private int total;
public Scan() {
in=System.in;
}
pu... |
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() {
ios::sync_with_stdio(false);
int n, k;
cin >> n >> k;
vector<bool> v = vector<bool>(n, false);
int a, l = 0, temp, nn = n;
for (int i = 0; i < k; i++) {
cin >> a;
temp = l;
for (int i = 0; i < a % nn; i++)
if (v[(temp + 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 ... | /*
The idea to solve this problem is by using index of child number in array instead of
using the child number itself.
If we are using index, we could get consistent behavior with mod formula. For example
if we want to move 7 times on circular array which have 7 elements starting from index
af... |
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(i) for i in input().split())
a = [int(i) for i in input().split()]
ms = [int(i) for i in range(1, n+1)]
cur = 0
for i in a:
ind = (i - n + cur) % n
n -= 1
cur = ind
print(ms.pop(ind), 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() {
int n, k, p;
while (~scanf("%d%d", &n, &k)) {
bool vis[n + 1];
int lins = n;
memset(vis, 0, sizeof(vis));
int i, leader = 0;
while (k--) {
scanf("%d", &p);
p %= n;
if (!p) {
printf("%d%c", leader + 1, k == 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;
int s[101];
int pos = 1;
int y[101];
for (int i = 1; i <= k; i++) cin >> s[i];
for (int i = 1; i <= n; i++) y[i] = i;
for (int i = 1; i <= k; i++) {
pos = (s[i] + pos) % n;
if (pos == 0) pos = n;
cout << y[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 ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.io.InputStream;
/**
* @author khokharnikunj8
*/
public class Main {
public static void ma... |
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())
arr = map(int, raw_input().split())
boys = range(1, n + 1)
lead = 0
for i in range(k):
index = (lead + (arr[i] % len(boys))) % len(boys)
print boys[index],
del(boys[index])
lead = index % len(boys)
|
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.security.KeyStore.Entry;
import java.util.*;
public class TestClass {
private static InputStream stream;
private static byte[] buf = new byte[1024];
private static int curChar;
private static int numChars;
private static SpaceCharFilter filter;
private static Pri... |
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 Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
Vector a=new Vector();
int n = input.nextInt();
int k = input.nextInt();
for (int i = 0; i < n; i++)
a.add... |
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 sys import stdout
n, k = map(int,raw_input().split()) # n children, k steps
a = map(int,raw_input().split()) # dice
c = range(1, n+1) # children
o = []
l = 0
for d in a:
l = (l + d) % len(c)
o.append(str(c[l]))
del c[l]
if l == len(c):
l = 0
print ' '.join(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.io.*;
import java.util.*;
public class B {
public static void main(String[] args)throws Throwable {
MyScanner sc=new MyScanner();
PrintWriter pw=new PrintWriter(System.out);
int n=sc.nextInt();
int k=sc.nextInt();
boolean [] removed=new boolean [n];
int [] a=new int [k];
int r=n;
for(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 ... | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.... |
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 u[111];
int main(void) {
long long n, k;
cin >> n >> k;
long long idx = 0;
for (long long i = 0; i < (long long)(k); i++) {
long long a;
cin >> a;
long long m = a % (n - i);
while (m) {
idx = (idx + 1) % n;
if (u[idx]) continue;
... |
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 ... | /**
* Created by Karan Jobanputra on 27-03-2017.
*/
import java.util.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class Main {
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[10... |
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.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class B {
public static void main(String[] args) throws IOException {
File inputFile = new File("entr... |
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;
int l = 0, x;
for (int i = 1; i <= n; i++) a.push_back(i);
for (int j = 0; j < k; j++) {
cin >> x;
l = (l + x) % n;
cout << a[l] << " ";
a.erase(a.begin() + l);
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.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class Check2
{
static class InputReader
{
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private Spac... |
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.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class ECR18Div2B {
public static void main(String[] args) {
FastScanner in=new FastScanner();
int n=in.nextInt();
int k=in.nextInt();
int[] ans=new 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>
int main() {
long long int N, M, i, j, k, a, b, c, d, x, y, z, t, s, m, n, p, q;
scanf("%lld %lld", &N, &t);
long long int A[t], B[N], C[t];
for (i = 0; i < t; i++) {
scanf("%lld", &A[i]);
}
for (i = 0; i < N; i++) {
B[i] = i + 1;
}
a = 1;
for (i = 0; i < t; 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.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 ... | num_children, num_steps = list(map(int, input().split(' ')))
counts_at_each_step = list(map(int, input().split(' ')))
def next_index_in_list(list_, index):
if index == len(list_) - 1:
return 0
return index + 1
def prev_index_in_list(list_, index):
if index == 0:
return len(list_) - 1
r... |
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
LI=lambda:list(map(int, sys.stdin.readline().split()))
MI=lambda:map(int, sys.stdin.readline().split())
SI=lambda:sys.stdin.readline().strip('\n')
II=lambda:int(sys.stdin.readline())
n, k=MI()
inp=[i for i in range(1, n+1)]
l=0
out=[]
for a in LI():
e=(l+a)%len(inp)
out.append(inp[e])
l=e
inp.pop(e)
pri... |
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())
kids = range(1,n+1)
popped = []
lead = 0
for i in range(k):
p = (lead + a[i])%len(kids)
popped.append(kids.pop(p))
lead = p%len(kids)
print ' '.join(map(str,popped))
|
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 = list(map(int, input().split()))
arr = list(map(int, input().split()))
child = list(range(1, n + 1))
main = 0
for i in range(k):
j = (main + arr[i]) % len(child)
print(child[j])
del child[j]
main = j % len(child)
|
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.StringTokenizer;
public class B {
public static void main(String[] args){
FastScanner scan = new FastScanner();
PrintWriter out = new PrintWriter(S... |
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 placementPreparation;
import java.util.*;
public class Codeforces {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int k= s.nextInt();
ArrayList<Integer> list = new ArrayList<>();
int [] arr = new int[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.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class Solution
{
static class InputReader
{
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilter filter;
... |
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() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, q;
cin >> n >> q;
vector<int> a(n);
vector<int> g(n);
iota(g.begin(), g.end(), 1);
for (int i = 0; i < q; i++) cin >> a[i];
int sz = n;
int k = 0;
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 main() {
long long int i, j, n, t, k;
cin >> n >> k;
long long int a[k + 1];
for (i = 0; i < k; i++) {
cin >> a[i];
}
vector<long long int> v;
for (i = 1; i <= n; i++) {
v.push_back(i);
}
long long int leader = 0;
for (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 ... | #include <bits/stdc++.h>
using namespace std;
list<int> a;
int main() {
int n, k;
scanf("%d %d", &n, &k);
a.clear();
for (int i = 1; i <= n; i++) {
a.push_back(i);
}
list<int>::iterator it = a.begin(), tmp;
while (k--) {
int m;
scanf("%d", &m);
m %= a.size();
for (int i = 0; i < m; 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 compare(const void *x1, const void *x2) {
return (*(int *)x1 - *(int *)x2);
}
int main() {
std::ios::sync_with_stdio(false);
int n, k;
cin >> n >> k;
int w = n;
bool *q = new bool[n];
int a;
for (int i = 0; i < n; ++i) {
q[i] = true;
}
int j = 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;
bool f[111];
int n, k;
int main() {
cin >> n >> k;
int now = 1;
int x;
for (int i = 0; i < k; i++) {
cin >> x;
x %= (n - i);
while (x) {
++now;
if (now == n + 1) now = 1;
if (f[now]) continue;
x--;
}
cout << 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 ... | import sys
n,k = map(int, input().split())
a = list(map(int, input().split()))
out = [False for i in range(n)]
i = 0
for j in range(k):
num = a[j] % (n - j)
while num > 0:
i= (i+1) % n;
if(not out[i]):
num-=1
out[i] = True;
print(i+1,end = ' ');
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 ... | #include <bits/stdc++.h>
using namespace std;
bool use[101];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long n, k;
long long a[101];
cin >> n >> k;
for (long long i = 0; i < k; i++) cin >> a[i];
long long pos = 0;
for (long long i = 0; i < k; i++) {
long long inc = a[i] % (n - i);... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.