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.util.*;
import javax.management.monitor.CounterMonitor;
import java.io.*;
import java.lang.*;
public class B {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String 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 ... | (n, k) = map(int, input().split(" "))
arr = list(map(int, input().split(" ")))
le = [i for i in range(-1, n-1)]
le[0] = n-1;
ri = [i for i in range(1, n+1)]
ri[n-1] = 0;
a = 0
ans = []
for i in arr:
i = i%n
for j in range(0, i):
a = ri[a]
ans.append(a+1)
le[ri[a]] = le[a]
ri[le[a]] = ri[a]
a = ri[a]
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 ... | #include <bits/stdc++.h>
using namespace std;
const int INF = 2e9 + 10;
int read() {
int xx = 0, ww = 1;
char ch = getchar();
while (ch > '9' || ch < '0') {
if (ch == '-') ww = -ww;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
xx = 10 * xx + ch - 48;
ch = getchar();
}
return xx * ww;... |
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 CountingOutRhyme {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt(), k = scan.nextInt(), id = 0;
ArrayList<Integer> list = new ArrayList<>();
for(int i = 1 ; i <= n ; i++)
list.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 ... | # -*- coding: utf-8 -*-
"""
Created on Mon Mar 27 08:13:42 2017
@author: kprashan
"""
n,k = [int(a) for a in input().rstrip().split()]
array = [int(a) for a in input().split()]
narray = [i for i in range(1,n+1)]
popArray = []
popIndex = 0
for i in range(0,k):
popIndex = (array[i] + popIndex)%len(narray)
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())
a = list(range(1,n+1))
leader = 0
for i in input().split():
e = (leader+int(i))%len(a)
print(a[e],end=' ')
a.pop(e)
leader = e |
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.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class Edu18B {
public static void main(String[] args) {
FS scan = new FS(System.in);
int N = scan.nextInt(), K = scan.nextInt();
ArrayList<Integ... |
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 INF = 0x3f3f3f3f;
const int maxn = 100 + 10;
vector<int> a;
int s[maxn];
int main() {
int n, k;
while (~scanf("%d%d", &n, &k)) {
a.clear();
for (int i = 1; i <= n; i++) a.push_back(i);
for (int i = 1; i <= k; i++) scanf("%d", s + i);
int st = 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())
ks = list(map(int, input().split()))
c = [(i + 1) for i in range(n)]
ind = 0
for i in range(k):
#print('c now', c)
d = (ind + ks[i]) % len(c)
ind = d
#print('del', c[d])#, end = ' ')
print(c[d], end = ' ')
del c[d]
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 compareup(const void *a, const void *b) { return (*(int *)a > *(int *)b); }
int comparedown(const void *a, const void *b) {
return (*(int *)a < *(int *)b);
}
void printArr(const vector<string> &a) {
for (int i = 0; i < a.size(); i++) cout << a[i] << endl;
cout << ... |
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, x;
vector<int> v;
int main() {
cin.sync_with_stdio(false);
cin >> N >> K;
for (int i = 0; i < (N); ++i) v.push_back(i);
int pos = 0;
for (int i = 0; i < (K); ++i) {
cin >> x;
x %= v.size();
pos = (pos + x) % v.size();
cout << v[pos] + 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.*;
import java.util.*;
public class CF792B {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
int k = Integer.p... |
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(0);
int n, k, h = 0;
cin >> n >> k;
vector<int> v;
for (int i = 0; i < n; i++) v.push_back(i);
for (int ki = 1; ki <= k; ki++) {
int x;
cin >> x;
x = x - (x / (n)) * (n);
int d = (h + 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 ... | /**
* DA-IICT
* Author : Savaliya Sagar
*/
import java.io.*;
import java.math.*;
import java.util.*;
public class B792 {
InputStream is;
PrintWriter out;
int n,k,a[];
ArrayList<Integer> ch = new ArrayList<>();
void solve() {
n= ni();
k = ni();
a = na(k);
for(int i=1;i<=n;i++){
ch.add(i);
}
int l... |
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> id(n);
for (int i = 0; i < n; i++) {
id[i] = i + 1;
}
int ptr = 0;
while (k--) {
int a;
cin >> a;
a %= id.size();
while (a--) {
++ptr;
if (ptr == id.size()) {
ptr = 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 ... | def solution(n, nums):
child = [x for x in range(1,n+1)]
#result = []
lead = 0
for a in nums:
steps = a%len(child)
borr = (lead + steps) % len(child)
#result.append(children[next_index])
print(child[borr] , end = " ")
del child[borr]
lead = borr
def main... |
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
foo = [int(x) for x in sys.stdin.readline().strip().split(" ")]
#print(foo)
n, k = foo
inp = [int(x) for x in sys.stdin.readline().strip().split(" ")]
people = [x for x in range(0, n)]
leader = 0
for a in inp:
removed_idx = (leader + a) % len(people)
print(people[removed_idx] + 1)
del people[removed... |
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())
B = list(map(int, input().split()))
A = [i for i in range(1, n + 1)]
x = 0
for i in range(k):
x = (x + B[i]) % len(A)
print(A.pop(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 ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, m;
int a[200];
int b[200];
while (~scanf("%d%d", &n, &k)) {
m = n;
for (int i = 0; i < k; i++) {
scanf("%d", &a[i]);
}
for (int i = 0; i < m; i++) {
b[i] = i + 1;
}
int lea[200];
int res[200];
lea[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.*;
public class Main {
static Scanner s = new Scanner(System.in);
public static void main(String __[]){
int n=s.nextInt(),ar[]=new int[s.nextInt()];
for(int i=0;i<ar.length;i++)
ar[i]=s.nextInt();
ArrayList<Integer> list = new ArrayList<>(100);
for(int i=1;i<=n;i++)
list.add(i);
int 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.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.LinkedList;
public class CountingOutRhyme {
public static void main(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 ... | import sys
n, k = map(int, sys.stdin.readline().strip().split(" "))
counts = list(map(int, sys.stdin.readline().strip().split(" ")))
children = list(range(n + 1))
children.pop(0)
pos = 0
for a in counts:
subarray = children[pos + 1:]
dif = a - len(subarray)
if dif <= 0:
pos += a
print(chil... |
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;
vector<int> v;
scanf("%d %d", &n, &k);
for (int i = 0; i < n; i++) v.push_back(i + 1);
int leader = 0;
for (int i = 0; i < k; i++) {
int a;
scanf("%d", &a);
leader = (leader + a) % (n - i);
printf("%d ", v[leader]);
v.e... |
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 = [int(i) for i in input().split()];
mass = [];
printmass = '';
count = n;
now = 0;
for i in range(n):
mass.insert(i,i+1);
for i in range(k):
a[i] = (a[i]+now) % count;
printmass += str(mass[a[i]]) + ' ';
del mass[a[i]];
now = a[i];
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 ... | n, k = map(int, input().strip().split(" "))
arr = list(map(int, input().strip().split()))
children = list([i + 1 for i in range(n)])
answer = []
i = 0
for ai in arr:
i = (i + ai) % n
answer.append(str(children[i]))
del children[i]
n -= 1
print(" ".join(answer)) |
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 stdin, stdout
n , k = [int(x) for x in stdin.readline().rstrip().split()]
nextPivot = [int(x) for x in stdin.readline().rstrip().split()]
Circle = range(1,n+1)
for i in range(k):
print Circle[(nextPivot[i])%n],
Circle=Circle[(nextPivot[i])%n+1:]+Circle[0:(nextPivot[i])%n]
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())
l=list(map(int,input().split()))
temp=[]
for i in range(n):
temp.append(i+1)
x=0
i=0
mlist=[]
while k!=0:
y=l[i]%n
z=x+y
if z>n-1:
w=z%n
else:
w=z
mlist.append(temp[w])
temp.pop(w)
x=w
i+=1
n-=1
k-=1
print(*mlist)
... |
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 double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const long long LINF = INF * (long long)INF;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<int> ch(n);
for (int i = (0); i < (n); i++) {
ch[i] = 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;
template <class T1>
void deb(T1 e) {
cout << e << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
cout << e1 << " " << e2 << " " << e3 << endl;
}
... |
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 = 105;
int n, k;
vector<int> a;
int arr[N];
int main() {
cin >> n >> k;
for (int i = 1; i <= k; ++i) {
cin >> arr[i];
}
a.clear();
a.resize(n);
for (int i = 0; i < n; ++i) {
a[i] = i;
}
int ptr = 0;
for (int i = 1; i <= k; ++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 N = 1e6 + 10;
int a[N];
int main() {
int n, k;
while (cin >> n >> k) {
for (int i = 1; i <= k; i++) cin >> a[i];
int sum = 0;
int vis[1000];
memset(vis, 0, sizeof(vis));
int x = 0;
int qq = n;
for (int i = 1; i <= k; 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 ... | import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;
public class QI {
private Scanner sc;
public static void main(String[] args) {
new QI().go();
}
private void go() {
sc = new Scanner(System.in);
int num = sc.nextInt();
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 ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.IntStream;
public class Main {
public static void main(String[] args) throws IOException {
FastScanner ... |
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;
queue<int> q;
int n, k;
int a;
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++) q.push(i);
for (int i = 0; i < k; i++) {
cin >> a;
a = a % n;
while (a--) {
int t = q.front();
q.pop();
q.push(t);
}
cout << q.front() << " ";... |
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 stack[105], top_index;
void pop() {
if (top_index == 0) return;
stack[top_index - 1] = -1;
top_index--;
}
void push(int num) { stack[top_index++] = num; }
int top() {
if (top_index == 0) return 0;
return stack[top_index - 1];
}
int main() {
int nChild, eliminate_index, leader_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 java.util.*;
public class JavaApplication26 {
public static void main(String args[]){
Scanner in = new Scanner(System.in);
int children_count = in.nextInt();
int gaps = in.nextInt();
ArrayList children = new ArrayList();
for(int i=1; i<=children_count; 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() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int n, k;
cin >> n >> k;
vector<int> numbers(n);
for (int i = 0; i < n; ++i) {
numbers[i] = i + 1;
}
vector<int> rounds(k);
for (int i = 0; i < k; ++i) {
cin >> rounds[i];
}
int 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.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public ... |
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 = 0;
cin >> n >> k;
long long steps[k];
int kids[n];
for (int i = 0; i < k; i++) {
cin >> steps[i];
}
for (int i = 0; i < n; i++) {
kids[i] = i + 1;
}
for (int i = 0; i < k; i++) {
cout << kids[(steps[i] + 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 ... | n,k = map(int, input().strip().split(' '))
lst = list(map(int, input().strip().split(' ')))
l=[]
for i in range(1,n+1):
l.append(i)
i2=1
for i in range(1,k+1):
k1=(lst[i-1]+i2)%(n-i+1)
print(l[k1-1],end=" ")
ind=l.index(l[k1-1])
if l[ind]==l[-1]:
i2=1
else:
i2=k1
del l[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.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
Tas... |
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 = [x+1 for x in range(n)]
x = map(int,raw_input().split())
s = 0
for i in range(k):
index = (s + x[i])%len(arr)
print arr[index],
del arr[index]
s = index%len(arr) |
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())
res = []
kids = range(1,n+1)
for m in a:
m %= len(kids)
res += [kids[m]]
kids = kids[(m+1):] + kids[:m]
print ' '.join(map(str,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 sys
import math
sys.setrecursionlimit(5000000)
def oi():
return int(raw_input().strip())
def ni():
return map(int, raw_input().strip().split(" "))
def os():
return raw_input().strip()
def ns():
return raw_input().strip().split(" ")
def nsolve(t):
for _ in xrange(t):
solve()
def modn(... |
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 ... | siz,qu = map(int,input().split())
ar,ind = [x for x in range(1,siz+1)],0
for k in map(int,input().split()):
nx = (ind + k) % siz
print(ar[nx])
siz -= 1; ar.pop(nx); ind = nx |
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 ll = long long;
using namespace std;
int n, k, a[110];
int main() {
ios::sync_with_stdio(false);
cin >> n >> k;
for (int i = 0; i < k; ++i) cin >> a[i];
vector<int> s;
for (int i = 1; i <= n; ++i) s.push_back(i);
int curr_leader = 0;
for (int i = 0; i < k; ++i) {
int eli... |
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 ... |
# coding: utf-8
# In[109]:
s = input()
n, k = s.split(' ')
n = (int) (n)
k = (int) (k)
# In[110]:
str = input()
a_s = str.split(' ')
a = []
for i in range(k):
a.append((int) (a_s[i]))
c = []
for i in range(n):
c.append(i + 1)
# In[111]:
am = n;
lead = 0;
for t in range(k):
p = (lead + a[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 ... | arr=map(int,raw_input().split(' '))
n=arr[0]
k=arr[1]
v=map(int,raw_input().split(' '))
num=[]
count =0
for k in xrange(1,n+1):
num.append(k)
leader = 0
out=[]
def deleteGame(leader,num,v):
for j in v:
#print leader
topop=(leader+j)%len(num)
out.append(num.pop(topop))
#print num
leader=topop
... |
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 = 105;
int n, k;
int a[Maxn];
vector<int> seq;
int main() {
scanf("%d %d", &n, &k);
for (int i = 0; i < k; i++) {
scanf("%d", &a[i]);
}
for (int i = 0; i < n; i++) {
seq.push_back(i);
}
int ind = 0;
for (int i = 0; i < k && seq.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 ... | n, _=map(int, input().split())
a=[i+1 for i in range(n)]
for m in map(int, input().split()):
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() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int TESTS = 1;
while (TESTS--) {
int l = 1, n, k, m;
cin >> n >> k;
m = n;
vector<long long int> b(n + 1);
for (long long int i = 1; i < n + 1; i++) b[i] = i;
vector<lo... |
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 in = new Scanner(System.in);
int n = in.nextInt();
int k = in.nextInt();
boolean[] b = new boolean[n];
int cur = 0;
int count = n;
while(k-->0) {
int a = in.nextInt();
a %= count;
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 ... | n, k = [int(x) for x in input().split(' ')]
steps = [int(x) for x in input().split(' ')]
steps.reverse()
circle = list(range(n))
index = 0
for i in range(len(steps)):
index = (index + steps.pop()) % len(circle)
print(circle[index] + 1, end=' ')
del circle[index]
|
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, q, ans, tst, i, a, k, cont, j, t, d, b, sum, p, m, l;
vector<int> v;
vector<long long> v2;
set<long long> st;
string s;
char c;
map<string, int> mp;
bool ah = false;
int main() {
cin >> n >> k;
for (i = 1; i <= n; i++) {
v.push_back(i);
}
for (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 ... | import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
public class Main {
static myScanner sc;
static PrintWriter pw;
public static void main(String[] args) throws IOException {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
//BufferedReader 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 math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().spl... |
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.*;
import java.lang.reflect.Array;
public class Main {
public static void main(String[] args) {
FastReader r = new FastReader();
int[] a = r.ria();
int[] moves = r.ria();
int[] people = new int[a[0]];
for(int i = 1; i<=a[0]; i++) {
people[i-1] = i;
}
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 ... | from sys import stdin
n, _ = map(int, stdin.readline().rstrip().split())
data = list(map(int, stdin.readline().rstrip().split()))
child = list(range(1, n + 1))
cur_pos = 0
rs = []
for index, count in enumerate(data):
count %= (n - index)
while count > 0:
cur_pos += 1
if child[cur_pos % n] != 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;
string mirror = "AHIMOTUVWXY";
string letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main() {
long long n, m, i, j, k, x, y, z, q, t;
cin >> n >> k;
vector<long long> a(k + 5), v, ans;
for (i = 0; i < k; i++) cin >> a[i];
for (i = 1; i <= n; i++) v.push_back(i);
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 ... | /*
* Author- Priyam Vora
* BTech 2nd Year DAIICT
*/
import java.io.*;
import java.math.*;
import java.util.*;
import javax.print.attribute.SetOfIntegerSyntax;
publi... |
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 : co_devil Chirag Garg
Institute : JIIT
"""
from __future__ import division, print_function
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
import heapq
from math import ceil,floor,log,sqrt,factorial,pow,pi
# from bisect import bisect_left,bisect_righ... |
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 = 100;
int a[N], n, k, was[N];
int main() {
scanf("%d%d", &n, &k);
for (int i = 0; i < k; ++i) scanf("%d", a + i);
int p = 0, shift, t = n;
for (int i = 0; i < k; ++i, --t, p = ++p % n) {
shift = a[i] % t;
for (; shift > 0 || was[p]; p = ++p % 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;
int main() {
int n, k;
cin >> n >> k;
int a[101];
int c[101];
for (int i = 0; i < k; i++) cin >> a[i];
for (int i = 1; i <= n; i++) c[i] = i;
int pos = 1;
for (int i = 0; i < k; i++) {
pos = (a[i] + pos) % n;
if (pos == 0) pos = n;
cout << c[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 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... |
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())
players = list(range(1, n+1))
leader = 0
for count in map(int,input().split()):
e = (leader + count) % n
print(players[e], end=' ')
players.pop(e)
leader = e
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 ... | def counting_out_rhyme():
n, k = input().split()
n, k = int(n), int(k)
a = [int(x) for x in input().split()]
nl = [i+1 for i in range(n)]
answer = []
for i in range(k):
count = a[i]
while True:
if count >= len(nl):
z = int(count/len(nl))
... |
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 ... | nn,k=map(int,input().split())
n=nn
a=list(map(int,input().split()))
c=list(range(1,n+1))
s=0
ans=[]
for j in a:
x=j%n
m=0
while m<x:
s+=1;s%=nn
while c[s]==-1:s+=1;s%=nn
m+=1
ans.append(str(c[s]))
c[s]=-1
n-=1
if n>0:
while c[s]==-1:s+=1;s%=nn
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 n, k;
deque<int> d;
int main() {
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 %= d.size();
while (a--) {
d.push_back(d.front());
d.pop_front();
}
int val ... |
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 whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new 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 ... | n, k = map(int, input().split())
a = list(map(int, input().split()))
used = [0] * n
ans = ""
cnt = 1
tmp = n
for i in range(k):
cur = a[i] % n
while cur > 0:
if used[cnt] == 0:
cur -= 1
cnt += 1
cnt = cnt % tmp
if cnt != 0:
ans += str(cnt) + " "
else:
... |
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())
s = [i for i in xrange(1,n+1)]
#print s
b = 0
for i in xrange(k):
e = (b+a[i])%(n-i)
#print e,s[e-1]
print s[e],
b = e
#print b
s.remove(s[e])
#print 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 ... | #include <bits/stdc++.h>
using namespace std;
long long n, k, m, t, mk = ((long long)(1e17 + 1)), q = 0;
long long a[int(3e5 + 600)];
vector<long long> v;
int main() {
cin >> n >> m;
v.resize(n);
for (int i = 1; i <= n; i++) v[i - 1] = i;
t = 0;
for (int i = 0; i < m; i++) {
cin >> k;
t = (t + k) % 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 ... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
void sci(T& t) {
cin >> t;
}
template <typename T, typename... Ts>
void sci(T& t, Ts&... ts) {
sci(t);
sci(ts...);
}
template <typename T, typename Cmp = std::greater<T>>
using heap = priority_queue<T, std::vector<T>, Cmp>;
bool out[111];
int mai... |
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 double pi = (2 * acos(0));
struct point {
long double x, y;
};
double area(int x1, int y1, int x2, int y2, int x3, int y3) {
double a =
(x2 * y3) - (x3 * y2) - (x1 * y3) + (x3 * y1) + (x1 * y2) - (x2 * y1);
a /= 2;
return fabs(a);
}
long double anyarea(p... |
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> d;
int n, k;
int main() {
cin >> n >> k;
for (int i = 0; i < n; i++) {
d.push_back(i + 1);
}
for (int i = 0; i < k; i++) {
int a;
cin >> a;
a %= d.size();
while (a--) {
d.push_back(d.front());
d.pop_front();
}
int 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 ... | from sys import stdout
def solve():
n, k = map(int, input().rstrip().split())
ls = list(map(int, input().rstrip().split()))
children = [i for i in range(1, n + 1)]
index = 0
for elt in ls:
index = (index + elt) % len(children)
stdout.write(str(children[index]) + ' ')
childre... |
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.ArrayList;
public class second{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), k = sc.nextInt();
ArrayList<Integer> data = new ArrayList<Integer>();
int[] step = new int[k];
for (int i = 0; i < k; i++)
step[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;
long long n, k;
long long ok[110];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
long long pos = 0;
for (long long i = 0; i < k; i++) {
long long a;
cin >> a;
vector<long long> v;
for (long long j = pos; j < pos + n; 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 ... | s = raw_input()
l = s.split(' ')
n = int(l[0])
m = int(l[1])
s = raw_input()
l = s.split(' ')
arr = []
for x in l:
arr.append(int(x))
num = []
for x in range(n):
num.append(x+1)
i = 0
loc = 0
while i < m:
j = (loc + arr[i]) % n
loc = j
print num[j],
n -= 1
num.pop(j)
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;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, k;
cin >> n >> k;
queue<int> q1, q2;
for (int i = 1; i <= n; i++) {
q1.push(i);
}
long long x;
for (int i = 0; i < k; i++) {
cin >> x;
int c = x % q1.size() + 1;
f... |
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 whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner in = new Scanner(System.in);
int 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;
int main() {
int n, k;
vector<int> v;
cin >> n >> k;
for (int i = 1; i <= n; i++) v.push_back(i);
for (int i = 1; i <= k; i++) {
int x;
cin >> x;
x %= v.size();
rotate(v.begin(), v.begin() + x, v.end());
cout << v[0] << " ";
v.erase(v.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 ... | n, a, b, l = input().split(), input().split(), [0], 1
n[0], n[1] = int(n[0]), int(n[1])
for i in range(1, n[0]+1): b.append(i);
for i in range(n[1]):
l = (l+int(a[i]))%n[0]
if l==0: l = n[0];
n[0]-=1
print(b[l], end = ' ')
b.pop(l) |
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, i, j, m, t = 1, a[105], f[105];
int main() {
cin >> n >> k;
for (i = 1; i <= k; i++) cin >> a[i];
for (i = 1; i <= n; i++) f[i] = i;
m = n;
for (i = 1; i <= k; i++) {
a[i] %= m;
if (a[i] != 0)
for (j = t + 1; a[i] > 0; j++) {
if (f[... |
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=lambda:map(int,raw_input().split())
n,k=l()
a=l()
x=range(1,n+1)
p=0
for i in range(k):
t=(p+a[i])%n
if t==n-1:
p=0
else:
p=t
print x.pop(t),
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 = list(map(int, input().split()))
cur = 0
x = []
for i in range(n):
x.append(i + 1)
for i in range(k):
v = cur
f = a[i] % n
for j in range(f):
v += 1
if v >= n:
v = v - n
print(x[v], end=' ')
x.pop(v)
n -= 1
cur = v % 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;
long long int n, i, j, k;
string s;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
vector<long long int> v;
for (i = 1; i <= n; i++) {
v.push_back(i);
}
long long int a[k];
for (i = 0; i < k; i++) {
cin >> 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 javax.swing.*;
import java.io.*;
import java.math.*;
import java.util.*;
// author @mdazmat9
public class codeforces{
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int test = 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.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.InputMismatchException;
public class Main {
InputStream is;
PrintWriter out;
String INPUT = "";
voi... |
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(f)for f in input().split()]
a=list(range(1,n+1))
l=0
for x in input().split():
e=(l+int(x))%len(a)
print(a[e],end=' ')
a.pop(e)
l=e
|
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 ... | #!/usr/bin/env python3
[n, k] = map(int, input().strip().split())
ais = list(map(int, input().strip().split()))
cur = 0
ch = list(range(1, n + 1))
l = []
for a in ais:
cur += a
cur %= len(ch)
l.append(ch[cur])
del ch[cur]
print (' '.join(map(str, l)))
|
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;
inline void read(int &x) {
short negative = 1;
x = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') negative = -1;
c = getchar();
}
while (c >= '0' && c <= '9')
x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
x *= negative;
}
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, input().split())
a = list(map(int, input().split()))
pos = 0
d = []
m = n
R = list(range(0, n))
for i in range(k):
s = a[i] % (n - i)
pos = pos + s
if pos >= (n - i):
pos -= n - i
d.append(R[pos] + 1)
R.remove(R[pos])
if pos >= (n - i):
pos -= n - i
print(*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 ... | import java.util.*;
public class cf
{
public static void main(String [] ars)
{
Scanner s = new Scanner(System.in);
int n=s.nextInt();
int k=s.nextInt();
ArrayList<Integer> al = new ArrayList<Integer>();
for(int i=0;i<n;i++){
al.add(i+1);
}
int i =0;
while(k-->0)
{
int ai=s.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 ... | #include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long lcm(long long a, long long b) { return (a * (b / gcd(a, b))); }
int main() {
int start = 0, n, k;
cin >> n >> k;
vector<int> players(n);
for (int i = 0; i < n; ++i) {
play... |
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 ... | st = raw_input().split(' ')
n = int(st[0])
k = int(st[1])
vis = ['true'] * (n+4)
str_arr = raw_input().split(' ')
arr = [int(num) for num in str_arr]
curr = 1
ans = list()
for x in arr:
x = x % (n-len(ans))
while x>0:
curr += 1
if curr>n:
curr = 1
while vis[curr] == 'false':
curr += 1
if curr>n:
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 ... | n, k = map(int, raw_input().strip().split())
x = map(int, raw_input().strip().split())
z = range(1, n+1)
l = 0
ans = []
for i in xrange(k):
l = (l+x[i])%len(z)
ans.append(z[l])
z = z[:l] + z[l+1:]
print ' '.join(map(str, 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 n, k, m;
int a[110];
int korak(int x) {
do {
x++;
if (x == n) {
x = 0;
}
} while (a[x] == 0);
return x;
}
int main() {
cin >> n >> k;
m = n;
for (int i = 0; i < n; i++) {
a[i] = i + 1;
}
int x = 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 ... | #include <bits/stdc++.h>
using namespace std;
int a[110] = {0};
int main() {
int n, k, x;
scanf("%d%d", &n, &k);
int cnt, first = 1, ans;
for (int i = 0; i < k; i++) {
scanf("%d", &x);
cnt = x % (n - i);
if (cnt == 0) cnt = n - i;
for (int i = first + 1;; i++) {
if (i > n) i = 1;
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 ... | #include <bits/stdc++.h>
using namespace std;
const int INF = 2e9 + 10;
int read() {
int xx = 0, ww = 1;
char ch = getchar();
while (ch > '9' || ch < '0') {
if (ch == '-') ww = -ww;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
xx = 10 * xx + ch - 48;
ch = getchar();
}
return xx * ww;... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.