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 ... | n,k = map(int,raw_input().split())
a = map(int,raw_input().split())
s = range(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 ... | import java.io.*;
import java.util.*;
public class CF_B {
public static void main(String[] args) throws Exception {
FastScanner fs = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
StringBuilder res = new StringBuilder();
int n = fs.nextInt(), k = fs.nextInt(), le... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.TreeMap;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
ArrayList<Integer> nums = new 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 ... | #include <bits/stdc++.h>
using namespace std;
int n, k, cap, a[105];
bool alive[105];
int next(int first) {
first = (first + 1) % n;
while (!alive[first]) first = (first + 1) % n;
return first;
}
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++) ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 a[102];
vector<long long int> v;
int main() {
long long int n, k;
cin >> n >> k;
for (long long int i = 0; i < k; i++) cin >> a[i];
for (long long int i = 0; i < n; i++) v.push_back(i);
long long int s = 0, siz = n;
long long int val = 0;
for (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.math.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
List<Integer> list = new ArrayList<Integer>();
int n = scanner.nextInt();
int k = scanner.nextInt();
int cur = 0;
for (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 ... | #include <bits/stdc++.h>
using namespace std;
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];
vector<long long> v;
for (long long i = 1; i <= n; i++) v.push_back(i);
for (long long 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;
const int MAX_N = 205;
const int MAX_M = 20005;
const int inf = 1000000007;
const int mod = 1000000007;
int n, m, k, N;
int a[MAX_N];
int main() {
cin >> N >> k;
n = N;
memset(a, 1, sizeof(a));
int s = 1;
while (k--) {
int x;
cin >> x;
x = x % n;
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 ... | n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
children = list(range(1, n + 1))
pos = 0
for i in range(k):
pos = (pos + a[i]) % len(children)
print(children[pos], end = ' ')
del children[pos]
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 n, k, x, p = 0, k2;
vector<int> V;
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++) {
V.push_back(i);
}
for (int i = 0; i < k; i++) {
cin >> x;
p = (p + x) % n;
cout << V[p] << " ";
V.erase(V.begin() + 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>
bool vis[150];
int main() {
int n, k, beg = 0;
scanf("%d %d", &n, &k);
memset(vis, false, sizeof(vis));
for (int i = 0; i < k; i++) {
int x;
scanf("%d", &x);
int s = x % (n - i);
while (s) {
beg++;
if (beg == n) beg = 0;
if (vis[beg]) continue;
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;
int main() {
int n, k;
cin >> n >> k;
vector<int> circle(n);
std::iota(circle.begin(), circle.end(), 1);
long long leader = 0;
for (int i = 0; i < k; ++i) {
long long myk;
cin >> myk;
long long todel = (leader + myk) % n;
cout << circle[todel] <<... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 check2;
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 numCh... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 = 0x7fffffff;
const long long INFF = 0x7fffffffffffffff;
const double pi = 3.141592653589793;
const double eps = 1e-8;
const long long mod = 1e9 + 7;
int a[105];
struct nodes {
int id;
int value;
friend bool operator<(struct nodes a, struct nodes b) {
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 v[105];
vector<int> a;
vector<int>::iterator it;
int main() {
int n, k;
scanf("%d %d", &n, &k);
for (int i = 1; i <= n; i++) a.push_back(i);
for (int i = 0; i < k; i++) {
scanf("%d", &v[i]);
}
int lead = 1;
for (int i = 0; i < k; i++) {
v[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 ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.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 ... | from collections import deque
from sys import stdin
lines = deque(line.strip() for line in stdin.readlines())
def nextline():
return lines.popleft()
def types(cast):
return list(int(x) for x in nextline().split())
def ints():
return types(int)
def strs():
return nextline().split()
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 ... | def read(func=int, is_list=False):
if is_list:
return map(func, raw_input().split())
else:
return func(raw_input())
n, k = read(int, True)
b = read(int, True)
a = [i for i in range(1, n + 1)]
def step(a, val):
sz = len(a)
cur = val % sz
nxt = (cur + 1) % sz
ind = a[cur]
res... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, k;
cin >> n >> k;
vector<long long> v;
for (long long i = 1; i <= n; i++) {
v.push_back(i);
}
for (long long i = 0; i < k; i++) {
long long a;
cin >> a;
a %= 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 std::vector;
int main() {
int ans[105];
int n, k;
scanf("%d%d", &n, &k);
vector<int> v;
for (int i = 1; i <= n; i++) v.push_back(i);
int x = 1;
for (int i = 0; i < k; i++) {
int y;
scanf("%d", &y);
x = (x + (y - 1) % (n - i) + 1 - 1) % (n - i) + 1;
ans[i] = 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;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int n, i, d;
cin >> n >> d;
vector<long long int> vec(d);
for (i = 0; i < d; i++) cin >> vec[i];
long long int lead = 0, tobere;
vector<long long int> a;
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.util.Scanner;
public class Counting_out_Rhyme {
static int k;
static int n;
static int total;
private static int count(int[] a,int count,int current){
if(current>n-1){
current = current-n;
}
while(a[current]==0){
current += 1;
if(current>n-1){
current = current-n;
}
}
int cou... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int a[110];
int main() {
int n, m;
cin >> n >> m;
vector<int> v;
for (int i = 0; i < m; i++) cin >> a[i];
for (int i = 1; i <= n; i++) v.push_back(i);
int lea = 0;
for (int i = 0; i < m; i++) {
lea = (lea + a[i]) % v.size();
cout << v[lea] << " ";
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
public static InputReader in;
public static PrintWriter pw;
public static void main(String args[]) {
new Thread(null, new Runnable() {
pub... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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=[i for i in range(n)]
leader=0
K=list(map(int,input().split()))
for i in K:
leader+=i
leader%=n
print(l[leader]+1,end=" ")
del l[leader]
n-=1
leader%=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 ... | def plus(a):
global n
a += 1
a = a % n
return a
n, k = map(int, input().split())
a = list(map(int, input().split()))
p = [1]*n
qwer = n
index = 0
for i in range(k):
res = 0
while res != a[i]%qwer:
index = plus(index)
res += p[index]
p[index] = 0
qwer -= 1
print(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 ... | n, k = map(int,input().split())
ai = list(map(int,input().split()))
ai2 = list(range(1,n+1))
num = 0
for i in range(k):
num = num + ai[i]
num %= n
print(ai2[num],end=" ")
n -= 1
ai2.remove(ai2[num])
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
const long long int hell = (long long int)(1e18 + 100LL);
int main() {
long long int t, i, j, k, m, n, x, y;
t = 1;
while (t--) {
long long int flag = 0;
cin >> n >> k;
vector<long long int> ar(k);
for (i = 0; i < k; i++) cin >> ar[i];
long long in... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n,k = map(int, raw_input().split())
A = map(int, raw_input().split())
L = []
for j in range(1,n+1):
L.append(j)
p = 0
B = []
for i in range(k):
X = len(L)
p = (p+A[i])%X
B.append(L[p])
L.remove(L[p])
p = p%(X-1)
for l in B:
print 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 ... | import static java.lang.Double.parseDouble;
import static java.lang.Integer.max;
import static java.lang.Integer.min;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.StrictMath.abs;
import static java.lang.System.exit;
import static java.util.Arrays.sort;
import... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 find_eliminatee(l, offset):
c = l
for _ in range(offset):
c = next(c)
return c
def next(c):
t = (c+1) % len(es)
while es[t]:
t = (t+1) % len(es)
return t
n,k = map(int, input().split())
a = list(map(int, input().split()))
l = 0
es = [False]*n
for i in range(k):
e = fin... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 {
public static void main(String[] args) {
Scanner write = new Scanner(System.in);
int N = write.nextInt();
int K = write.nextInt();
List<Integer> list = new LinkedList<>();
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 ... | n,k=map(int,input().split())
a=list(map(int,input().split()))
ele=[(j+1) for j in range(n)]
j=0
e=[]
for i in range(k):
j=(j+a[i])%len(ele)
m=ele.pop(j)
e.append(m)
for j in range(len(e)):
print(e[j],end=" ")
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 ... | import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
public class B792 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
int K = in.nextInt();
int[] A = new int[K];
for (int k=0; k<K; 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 ... | #Let's go
import sys
import math
import random
sys.setrecursionlimit(100000)
n, k = map(int, input().split())
ar=[i+1 for i in range(n)]
for m in map(int, input().split()):
m%=len(ar)
print(ar[m], end=" ")
ar=ar[m+1:] + ar[: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 ... |
import java.util.*;
import java.io.*;
public class B792 {
public static void main(String[] args) {
InputReader s = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
/*My code starts here.*/
int n = s.nextInt(),k = s.nextInt();
ArrayList<Integer>arr = new ArrayList<Integer>();
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 ... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
return (b ? __gcd(a, b) : a);
}
template <typename T>
T lcm(T a, T b) {
return (a * (b / gcd(a, b)));
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
os << "[ ";
for (auto v : V) os << v << " ";
return 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.ArrayList;
import java.util.StringTokenizer;
public class ProblemA {
public static void solve(InputReader in, PrintWriter out) throws IOException{
int n = in.nextInt();
int k = in.nextInt();
int[] a = new int[k];
ArrayList<Integer> child = new 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 ... | #include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
const long double eps = 1e-8;
template <typename T>
void cmin(T &x, T y) {
x = y < x ? y : x;
}
template <typename T>
void cmax(T &x, T y) {
x = y > x ? y : x;
}
long long read() {
char ch = getchar();
long long x = 0;
int op = 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.math.*;
import java.util.*;
public class B {
final static int MOD = 1000000007;
static int[] a;
static ArrayList<Integer> l = new ArrayList<>();
public static void main(String[] args) throws Exception {
FastReader in = new FastReader(System.in);
int n = in.nextInt();
int k = 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 ... | from collections import Counter
import sys
f = sys.stdin
#f = open('Counting-out_Rhyme.txt')
n, k = map(int, f.readline().split())
c = map(int, f.readline().split())
dp = [0]*n
br = range(n)
ans = []
p = 0
idx = 0
n2 = n
for i in xrange(0, k):
k2 = c[i] % n2
j = 0
while j < k2:
idx += 1
idx... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
void solve() {
long long n, k, i, A[105], l, x, id, e, j;
cin >> n >> k;
for (long long(i) = 0; (i) < (n); (i) = (i + 1)) {
A[i] = i + 1;
}
l = 0;
for (long long(i) = 0; (i) < (k); (i) = (i + 1)) {
cin >> x;
id = x % n + l;
if (id > 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 ... |
var tmp = readline().split(' ').map(function(x) {
return parseInt(x);
});
var n = tmp[0];
var k = tmp[1];
var d = readline().split(' ').map(function(x) {
return parseInt(x);
});
var children = new Array(n).fill(0).map(function(x, i) {
return i + 1;
});
var curr = 0;
var res = [];
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 ... | #include <bits/stdc++.h>
using namespace std;
vector<bool> visited(100005, false);
vector<long long> adj[100005];
vector<long long> parent(100005, -1);
long long ans1;
long long expo(long long x, long long n, long long M) {
if (n == 0)
return 1;
else if (n % 2 == 0)
return (expo((x * x) % M, n / 2, M)) % 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;
vector<int> vec;
int n, k, a[105], b[105], vis[105];
int main() {
while (~scanf("%d%d", &n, &k)) {
for (int i = 0; i < k; i++) scanf("%d", &a[i]);
vec.clear();
for (int i = 1; i <= n; i++) {
vec.push_back(i);
}
int cnt = 0, t = 0;
for (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 ... | #include <bits/stdc++.h>
using namespace std;
vector<int> v;
int n, k;
int main() {
cin >> n >> k;
int a;
for (int i = 1; i <= n; i++) v.push_back(i);
int pos = 0;
for (int i = 0; i < k; i++) {
cin >> a;
pos = (a + pos) % n;
cout << v[pos] << " ";
v.erase(v.begin() + pos);
n--;
}
retur... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k = map(int, input().split())
a = [int(i) for i in input().split()]
v = [int(i) for i in range(n)]
# print(v)
i = 0
cont = 0
tam = n
eli = []
while cont < k:
i = ((i+a[cont])%tam)
eli.append(v[i]+1)
v.pop(i)
# print(i)
# print(v)
cont += 1
tam -= 1
# i += 1
# print(i)
# 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 ... | import java.util.*;
import java.io.*;
public class b{
static InputReader in = new InputReader(System.in);
static PrintWriter out = new PrintWriter(System.out);
int n, k;
int[] a = new int[200];
int[] nxt = new int[200];
int[] prv = new int[200];
void solve(){
n = in.nextInt(); k = in.nextInt();
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 ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, p, q, s, z;
cin >> n >> k;
vector<int> v;
int i = 1;
while (i <= n) {
v.push_back(i);
i++;
}
i = 1;
q = 0;
while (i <= k) {
cin >> p;
s = (q + (p % (v.size()))) % v.size();
cout << v[s] << endl;
v.erase(v.begi... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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;
vector<int> s;
int main() {
scanf("%d%d", &n, &k);
s.clear();
for (int i = 1; i <= n; i++) s.push_back(i);
int p = 0;
for (int i = 1; i <= k; i++) {
int x;
scanf("%d", &x);
p = (p + x) % s.size();
cout << s[p] << endl;
s.erase(s.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 ... | import java.awt.List;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.*;
public class Watermelon {
public static void main(String[] args) 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 ... | import sys
def solve():
n, k = map(int, input().split())
ch = [i + 1 for i in range(n)]
a = [int(i) for i in input().split()]
live = n
leader = 0
ans = []
for v in a:
v = v % live
j = 0
cnt = 0
while cnt < v:
if ch[(leader + j + 1) % n]:
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
int n, k;
while (~scanf("%d%d", &n, &k)) {
long long int x;
for (int i = 1; i <= n; i++) v.push_back(i);
long long int tmp = 0;
while (k--) {
cin >> x;
tmp = (tmp + x) % n;
cout << v[tmp] << " ";
v.eras... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class First {
public static void main(String[] args){
InputStream 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 ... | #Bhargey Mehta (Sophomore)
#DA-IICT, Gandhinagar
import sys, math, queue
sys.setrecursionlimit(1000000)
#sys.stdin = open("input.txt", "r")
n, k = map(int, input().split())
a = list(map(int, input().split()))
c = [i for i in range(n)]
indx = 0
for i in range(k):
indx = (indx + a[i])%(n-i)
print(c.pop(indx)+1,... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.util.ArrayList;
import java.util.Scanner;
public class codeforces {
public static void main(String[] args) {
TaskB Solver = new TaskB();
Solver.Solve();
}
public static class TaskB {
public void Solve() {
Scanner in = 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())
a = list(map(int,input().split()))
lst = list(range(1,n+1))
leader = 0
for step in range(k):
index = (leader+(a[step]%n))%n
ans=lst[index]
print(ans,end =" ")
lst.remove(ans)
n-=1
leader=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;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
int main() {
int n, k;
cin >> n >> k;
vector<int> v(k);
for (int i = 0; i < k; ++i) cin >> v[i];
int a = 0;
vector<int> l(n);
for (int i = 0; i < n; ++i) {
l[i] = i + 1;
}
for (i... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) a[i] = i + 1;
int leader = 0;
while (k--) {
int hi;
cin >> hi;
int i = leader;
i = (i + hi) % a.size();
cout << a[i] << " ";
leader = i;
a.erase(a.beg... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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_K = 105;
int step[MAX_K];
int pos[MAX_K];
vector<int> res;
int main(void) {
int n, k;
scanf(" %d %d", &n, &k);
for (int i = 0; i < n; i++) {
pos[i] = i + 1;
}
for (int i = 0; i < k; i++) {
scanf(" %d", &step[i]);
}
int start = 0;
int 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 ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.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 ... | #include <bits/stdc++.h>
using namespace std;
int n;
int k;
int main() {
scanf("%d %d", &n, &k);
int ai;
int start = 0;
int res[110];
for (int i = 0; i < n; i++) res[i] = i;
while (k--) {
scanf("%d", &ai);
int resdel = (start + ai) % n;
printf("%d ", res[resdel] + 1);
start = resdel + 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 = 1
ans = []
b = [i for i in range(1, n+1)]
for i in range(k):
c = (c + a[i]-1)%n
ans.append(b[c])
b.pop(c)
n = n - 1
if n == 0:
break
c = (c + 1)%n
for i in ans:
print(i, end = " ")
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
ans = list(range(1, n + 1))
base = 0
for i in range(k):
base = (l[i] + base) % len(ans)
print(ans.pop(base)) |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int n, k;
int a[123], nxt[123], pre[123];
int main() {
cin >> n >> k;
for (int i = 0; i < k; i++) cin >> a[i];
for (int i = 1; i < n; i++) nxt[i] = i + 1;
nxt[n] = 1;
for (int i = 2; i <= n; i++) pre[i] = i - 1;
pre[1] = n;
int s = 1;
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.util.Arrays;
import java.util.Scanner;
import java.io.PrintWriter;
public class Solution {
public static void main(String[] args) throws Exception {
Solution solution = new Solution();
solution.run();
}
private void run() throws Exception {
Scanner scan = new Scanner(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 ... | child_num, step_max = map(int, input().split())
count_num = input()
count = [int(n) for n in count_num.split()]
leader = 0 # leader index initial
step = 0
num = 1
child = [] # eliminate children list
while num <= 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 ... | #include <bits/stdc++.h>
using namespace std;
const long dad = 1e4;
long n, boss = 1, a[dad], k;
bool kt[dad];
int main() {
cin >> n >> k;
for (long i = 1; i <= k; ++i) {
cin >> a[i];
a[i] = a[i] % (n - i + 1);
}
for (long i = 1; i <= k; ++i) {
for (long j = 1; j <= a[i]; ++j) {
++boss;
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 MyClass {
public static void main(String args[]) {
FastReader sc = new FastReader();
PrintWriter pw = new PrintWriter(System.out);
int n = sc.nextInt();
int k = sc.nextInt();
long a[] = new long[k];
long b[] = new long[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 ... | import java.io.*;
import java.util.*;
public class op {
public static void main(String[] args) throws IOException
{
int n=i();
int k=i();
//int a[]=new int[n+1];
int p=1;
int b[]=new int[n+1];
int g=n;
for(int y=0;y<k;y++)
{
int x=i();
int o=(x)%g;
int q=0;
for(int u=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 ... | n ,m= map(int,raw_input().split())
a = map(int,raw_input().split())
c = range(1,n+1)
leader = 0;
est = -1;
for i in range(m):
est = (leader+a[i])%len(c);
print c.pop(est)
leader = est
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 = list(map(int, input().split()))
# n, k = 7, 5
# lst = [10, 4, 11, 4, 1]
children = [i for i in range(1,n+1)]
output = []
front = 0
for i,a in enumerate(lst):
elim = (a+front) % (n-i)
child = children[elim]
front = children.index(child)
children.remove(child)
pr... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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];
bool used[N];
int main() {
int n, k;
cin >> n >> k;
for (int i = 0; i < k; i++) cin >> a[i];
int now = 0, size = n;
for (int i = 0; i < k; i++) {
a[i] = a[i] % size;
for (int j = 0; j < a[i]; j++) {
while (true) {
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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> gru;
for (int i = 0; i < n; i++) {
gru.push_back(i + 1);
}
long long lead = 1;
for (int i = 0; i < k; i++) {
long long a;
cin >> a;
lead += a;
lead = lead % gru.size();
if (lead == 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.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class B {
public static void main(St... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import sys
import bisect as bi
import math as mt
import collections as cc
import heapq as hp
I=lambda:list(map(int,input().split()))
n,k=I()
l=I()
ar=list(range(1,n+1))
now=0
for i in range(k):
cur=(now+l[i])%n
print(ar[cur],end=" ")
ar.pop(cur)
n=len(ar)
now=(cur)%n
#print(ar,now,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())
a = list(map(int, input().split()))
c = [(i + 1) for i in range(n)]
cur = 0
for i in range(k):
cur = (cur + a[i]) % len(c)
print(c[cur], end=' ')
c = c[:cur] + c[cur+1:]
# print(c, cur)
# cur = (cur + 1) % len(c)
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
vector<long long> a(k), b;
for (long long i = 0; i < k; i++) {
cin >> a[i];
}
for (long long i = 1; i <= n; i++) {
b.push_back(i);
}
long long i = 0;
long long leader;
long long pos = 1;
while (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.*;
import java.math.*;
import java.util.*;
/**
*
* @author Saju
*
*/
public class Main {
private static int dx[] = { 1, 0, -1, 0 };
private static int dy[] = { 0, -1, 0, 1 };
private static int dx1[] = { 1, 1, 0, -1, -1, -1, 0, 1 };
private static int dy1[] = { 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.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
import java.math.*;
public class Main
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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;
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(nullptr) {}
};
int main() {
ios::sync_with_stdio(false);
cin >> n >> k;
ListNode dummy(0);
ListNode *cur = &dummy, *prev;
for (int i = 1; i <= n; i++) {
cur->next = new 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 i, j, n, k;
cin >> n >> k;
vector<int> vct;
for (i = 1; i <= n; i++) vct.push_back(i);
long long int a;
long long int pos = 0;
for (i = 0; i < k; i++) {
cin >> a;
pos = (pos + a) % n;
cout << vct[pos] << " ";
vct.erase(vct.begi... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k = map(int, input().split())
a = [int(x) for x in input().split()]
ld = 0
ppl = list(range(1, n+1))
for rd in range(k):
ld = (ld + a[rd]) % len(ppl)
print(ppl[ld], end=' ')
ppl = ppl[:ld] + ppl[ld+1:]
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> v;
int main() {
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) v.push_back(i);
int t = 0;
for (int i = 0; i < k; i++) {
int x;
cin >> x;
t = (t + x) % n;
cout << v[t] << " ";
v.erase(v.begin() + t);
n--;
}
return 0;
}... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k = map(int, raw_input().split())
p = range(1,n+1)
a = map(int, raw_input().split())
start = 0
for i in xrange(k):
add = (start + a[i]) % n
print p[add],
del p[add]
start = add
n -= 1
if start == n:
start = 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 sys
input = sys.stdin.readline
I = lambda : list(map(int,input().split()))
n,k=I()
x=I()
l=[i+1 for i in range(n)]
an=[];cur=0
for i in range(k):
cr=(cur+x[i])%n
an.append(l[cr])
del l[cr]
n-=1
cur=cr
#print(l,cur)
print(*an) |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... |
n, k = map(int, input().split())
A = [int(x) for x in input().split()]
tab = list(range(1, n + 1))
leader = 0
result = []
for x in A:
leader = (leader + x) % len(tab)
result += [tab[leader]]
tab = tab[:leader] + tab[leader + 1:]
leader = leader % len(tab)
print(' '.join(map(str, result)))
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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);
int pos = 0;
for (int i = 0; i < k; ++i) {
int a;
cin >> a;
pos += a % v.size();
pos %= v.size();
cout << v[pos] << ' ';
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 ... | #include <bits/stdc++.h>
using namespace std;
int n, k, a[111], ans[111], now;
bool use[111];
int main() {
cin >> n >> k;
for (int i = 0; i < k; i++) {
cin >> a[i];
}
for (int i = 0; i < k; i++) {
int c = a[i] % (n - i);
for (int j = 0; j < c; j++) {
now++;
if (now >= n) {
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 ... | #include <bits/stdc++.h>
using namespace std;
int const INF = 1000000000;
const int MOD = 998244353;
const int N = 1e6 + 10;
const long double EPS = 3e-16;
void faster() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int simple(int n) {
int i, sq;
if (n % 2 == 0) {
return 0;
}
sq = (int)sq... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 ... | import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class CountingOutRhyme {
static Scanner sc=new Scanner(System.in);
public static void main(String[] args){
int n=sc.nextInt(),m=sc.nextInt();
int a[]=new int[m];
List<Integer> t=new ArrayList<Integer>();
for(int i=0;i<n;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;
ios::sync_with_stdio(false);
int a[500];
while (cin >> n >> k) {
int x = 0;
int num;
for (int i = 1; i <= n; i++) {
a[i] = i;
}
for (int i = 0; i < k; i++) {
cin >> num;
x += num;
x %= n;
if (i... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.util.Scanner;
public final class Main
{
private static int[] solve(int[] childs, int skip)
{
int n = childs.length;
int to = skip % n;
int[] nxt = new int[n - 1];
for(int i=0;i<n-1;i++)
nxt[i] = childs[(to + 1 + i) % n];
System.out.print(childs[to]);
return nxt;
}
public static void 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 ... | #include <bits/stdc++.h>
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
vector<long long> a, c;
for (int i = 1; i <= n; i++) c.push_back(i);
for (int i = 0; i < k; i++) {
long long t;
cin >> t;
a.push_back(t);
}
int leader = 0;
for (int i = 0; i < k; i++) {
int r = (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 ... | #include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[] = {0, 0, 1, -1, -1, 1, 1, -1};
int biton(int n, int pos) { return n = n | (1 << pos); }
int bitoff(int n, int pos) { return n = n & ~(1 << pos); }
bool bitcheck(int n, int pos) { return (bool)(n & (1 << pos)); }
inline int 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 namespace std;
int n, k, a[200];
vector<int> vt;
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++) vt.push_back(i);
int lead = 1;
for (int i = 1; i <= k; i++) {
cin >> a[i];
cout << vt[((lead + a[i]) % vt.size() + vt.size() - 1) % vt.size()] << " ";
int lea = le... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.util.*;
public class a {
// class Pair
// {
// int v;
// int e;
//
// public Pair(int v,int e)
// {
// this.v=v;
// this.e=e;
// }
// }
public static long newpos(long size,long pos,long shift)
{
if(size==1)
return 0;
if(pos+shift<size)
return pos+shift;
else
{
shift=sh... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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+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]
# Made By Mostafa_Khaled |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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())
b = list(range(1, n + 1))
p = 0
for i in range(k):
d = next(a) % len(b)
for j in range(d):
p = (p + 1) % len(b)
print(b[p], end=' ')
b.pop(p)
p %= len(b)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.