prompt string | response string |
|---|---|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int k = in.nextInt();
int[] players = new int[n];
for (int i=0 ; i<n ; i++) pl... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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);
const double eps = 1e-9;
bool chkb(long long x, long long p) { return (x & (1 << p)); }
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long i, j, k, l, p, q, x, y, z, n, m, c, t, h;
cin >> n >> k;
long 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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.*;
public class Main implements Runnable {
private void solve() throws IOException {
int... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.util.*;
public class codeforces {
public static void main(String args[]){
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.nextInt();
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 Counting {
public static void main(String args[]){
Scanner in = new Scanner(System.in);
int n=in.nextInt();
ArrayList a = new ArrayList();
for(int i=1;i<=n;i++) a.add(i);
int k=in.nextInt();
int l=0;
for(int i=0;i<k;i++){
int j=in.nextInt();
l=(l+j)%a.siz... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [i+1 for i in range(n)]
l = n
ans = []
ind = 0
x = 0
for i in range(k):
ind = ind + a[i]%l
if ind >= l:
ind -= l
ans.append(b.pop(ind))
l -= 1
print (*ans) |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int pos[109], npos[109];
int main() {
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; ++i) pos[i] = i;
for (int i = 1; i <= k; ++i) {
int cnt;
cin >> cnt;
int el = (1 + cnt) % n;
if (el == 0) el = n;
cout << pos[el] << " ";
int nw = 0, 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 ... | # Codefores 792B
n, k = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
childs = [i for i in range(n)]
leader = 0
deads = []
for i in range(k):
dead = (leader + a[i]) % n
deads.append(str(childs[dead] + 1))
childs.pop(dead)
n -= 1
leader = dead
print(' '.join(dead... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k = map(int, input().split())
a = list(map(int, input().split()))
lead = 0
lst = []
for i in range(1, n + 1):
lst.append(i)
for i in range(k):
ind = (lead + a[i])%len(lst)
print(lst[ind], end=" ")
lead = ind
lst[ind] = -1
llst = []
for j in range(len(lst)):
if lst[j] != -1:llst.ap... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int i = 0, n, l = 0, k = 0, b = 0, c = 0, e, x, j, m, d, t = 0,
sum = 0, f = 0, o, z = 0, h = 0, y, r, x1, x2, y1, y2;
cin >> n >> k;
vector<long long int> v, v1;
for (i = 1; i < n + 1; i++) {
v.push_back(i);
}
for (i =... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
bool vs[maxn];
int main() {
int n, k;
bool first = 1;
int sum;
scanf("%d%d", &n, &k);
sum = n;
memset(vs, 1, sizeof vs);
int now = 0, t;
for (int i = 0; i < k; i++) {
scanf("%d", &t);
for (int j = 0; j < t % sum; j++) {
no... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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, s = 0;
deque<int> d;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
;
cin >> n >> k;
int arr[n + 5];
for (int i = 0; i < n; i++) d.push_back(i);
for (int i = 0; i < k; i++) cin >> arr[i];
for (int i = 0; i < k; i++) {
int e = (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;
template <class T>
inline T bigmod(T p, T e, T M) {
long long ret = 1;
for (; e > 0; e >>= 1) {
if (e & 1) ret = (ret * p) % M;
p = (p * p) % M;
}
return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
if (b == 0) return a;
return gcd(b, a % 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 ... | n, x=map(int, input().split())
a=[]
for x in range(1,n+1):
a.append(x)
b=list(map(int, input().split()))
for z in b:
z%=len(a)
print(a[z], end=' ')
a=a[z+1:]+a[:z]
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 practice_problems;
import java.io.*;
import java.util.*;
import java.math.*;
/**
*
* @author Tushar Mar 27, 2017
*/
public class B_792 {
public static void main(String args[])
{
//File file= new File("COMPLETE_FILE_PATH");
//InputStream is = new FileInputStream(file);
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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[500010];
int main() {
int n, k;
scanf("%d %d", &n, &k);
for (int i = 0; i < n; i++) {
a[i] = i;
}
int tmp;
int leader = 0;
int size = n;
for (int i = 0; i < k; i++) {
if (i) printf(" ");
scanf("%d", &tmp);
leader = (leader + tmp) % 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 ... | import java.util.ArrayList;
import java.util.Scanner;
/**
* Created by msi on 3/28/2017.
*/
public class CountingoutRhyme {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n, k;
n = in.nextInt();//children
k = in.nextInt();//steps
Array... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 B {
private static Scanner in = new Scanner(System.in);
public static void main(String[] args) {
int N = in.nextInt();
int K = in.nextInt();
boolean[] out = new boolean[N];
int head = 0;
int[] outs = new int[K];
for (int k = 0; k < K; k++) {
int moves = (in.nex... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
template <typename X>
inline X abs(const X& a) {
return a < 0 ? -a : a;
}
template <typename X>
inline X sqr(const X& a) {
return a * a;
}
const int size = 1e5 + 2;
const double eps = 0.0001;
const long double PI = 3.1415926535897932384626433832795;
const long long MOD ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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> g;
int main() {
int n, k;
cin >> n >> k;
long long a;
for (int i = 1; i <= n; ++i) g.push_back(i);
int king = 0;
for (int i = 1; i <= k; ++i) {
cin >> a;
int cd = (a + king) % g.size();
cout << g[cd] << " ";
g.erase(g.begin() + cd);
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import sys
n,k = map(int,input().split())
a = list(map(int,input().split()))
num = [i for i in range(1,n+1)]
leader = 0
for i in range(k):
if a[i] == n:
pos = leader
elif a[i] > n:
a[i] = a[i] % n
pos = leader + a[i]
if leader + a[i] >= n:
a[i] -= n-1-leader
pos = a[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()))
lead = 0
people = [i + 1 for i in range(n)]
for d in a:
nex = (lead + d) % n
print(people[nex])
del people[nex]
n -= 1
nex %= n
lead = nex
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
const long long inf = INT_MAX;
long long n, k, a[100001];
bool b[100001];
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cerr.tie(0);
cout.tie(0);
cin >> n >> k;
for (long long i = 0; i < k; i++) {
cin >> a[i];
}
long long ld = 1;
for (... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.util.ArrayList;
import java.util.Scanner;
/**
* Created by Gantushig on 3/27/2017.
*/
public class B {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n = input.nextInt(), k = input.nextInt(), ai, index = 0;
ArrayList<Integer> list = new... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 Children
{
public static void main(String args[])throws Exception
{
int n,k,i,j=1,l,rem,m;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
k=sc.nextInt();
int ans[]=new int[n];
for(i=0;i<n;i++)
ans[i]=1;
int ar[]... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | a=list(map(int, input().split()))
n=a[0]
k=a[1]
b=list(map(int, input().split()))
l=[0]*n
for i in range(n):
l[i]=i+1
ans=[]
for i in range(k):
c=b[i]
g=len(l)
j=c%g
ans.append(l[j])
l.pop(j)
l=l[j:]+l[:j]
print(*ans) |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n,k = map(int,raw_input().split())
a = range(1,n+1)
g = map(int,raw_input().split())
p = 0
for i in g:
ag = i%len(a)
#print p,ag,
p += ag
p%=len(a)
print a[p],
del a[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;
long long arr[1000];
bool mark[1000];
long long a, b;
int main() {
cin >> a >> b;
for (int i = 0; i < b; i++) {
cin >> arr[i];
}
int pos = 1;
for (int i = 0; i < b; i++) {
for (int j = 0; j < arr[i] % (a - (i)); j++) {
pos++;
if (pos > a) {
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k = map(int, input().split())
a = list(map(int, input().split()))
def round(children, a, leader):
lead_pos = children.index(leader)
a = (lead_pos + a) % len(children)
deleted = children[a]
del(children[a])
return children, a % len(children), deleted
children = list(range(1, n+1))
result = []
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 ... | ip = input().split(' ')
n = ip[0]
k = ip[1]
ip2 = input().split(' ')
a = list(map(int, ip2))
children = []
for x in range(int(n)):
children.append(x+1)
temp = 0
for y in a:
print(children[((temp+y)%len(children))])
temp = children.index(children[((temp+y)%len(children))])
del(children[temp])
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 raw_input().split()]
a = [int(x) for x in raw_input().split()]
lead = 0
kids = range(1, n + 1)
for i in range(k):
out = (lead + a[i]) % n
print kids.pop(out)
n -= 1
lead = out |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<int> x(k);
for (int i = 0; i < k; i++) cin >> x[i];
vector<int> y(n);
for (int i = 0; i < n; i++) y[i] = i;
int pre = 0;
for (int i = 0; i < k; i++) {
pre += x[i];
pre %= y.size();
cout << y[pre] + 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)=list(map(int,input().split()))
input2=list(map(int,input().split()))
outputlist=[]
currentl=[i for i in range(1,n+1)]
ved=0
for i in range(len(input2)):
number=input2[i]%len(currentl)
while number>0:
ved+=1
ved%=len(currentl)
number-=1
outputlist.append(currentl[ved])
del 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>
int n, m;
int a[111];
void nxt(int &x) {
x++;
if (x > n) x = 1;
}
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) a[i] = i;
int cur = 1;
for (int i = 0; i < m; i++) {
int x;
scanf("%d", &x);
x %= (n - i);
for (int j = 0; j < x; j++) {
nxt(cur);... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, k;
cin >> n >> k;
vector<long long int> v;
for (long long int i = 1; i < n + 1; i++) v.push_back(i);
long long int leader = 0;
long long int x;
while (k--) {
cin >> x;
long long int cnt = (leader + x) % n;
cout << v[cn... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
public class April_2 {
public static void main(String [] args) throws IOException {
f792_b();
}
public 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 ... | n, k=map(int, input().split())
a=[x+1 for x in range(n)]
for m in map(int, input().split()):
m%=len(a)
print(a[m], end=" ")
a=a[m+1:]+a[:m]
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;
const long double pi = 3.14159265358979323846;
const long long mod = 1e9 + 7;
const long long N = 5e5;
const long long INF = 1e9 + 1;
long long n, m, a[N], p;
vector<long long> v;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(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 Counting {
static Scanner in;
static int[] turns;
static ArrayList<Integer> Childs;
static int n, k, leader = 1, aux, j = 0;
public static void main(String[] args) {
in = new Scanner(System.in);
n = in.nextInt();
k = in.nextInt();
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k = map(int, raw_input().split())
arr = map(int, raw_input().split())
active = range(1, n + 1)
cur = 0
for i in range(k):
to_elim = (cur + arr[i]) % len(active)
print active[to_elim],
del active[to_elim]
cur = to_elim % len(active)
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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()))
array = [0] * n
for i in range (n):
array[i] = i + 1
now = 0
for i in range (k):
dp = (now + a[i] % len(array)) % len(array)
print(array[dp], end = " ")
array.pop(dp)
now = dp
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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()))
j=0
L=list(range(1,n+1))
for i in l:
k-=1
j=(j+i)%n
if k!=0:
print(L[j],end=' ')
else :print (L[j],end='')
n-=1
L.pop(j)
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | def find_eliminatee(l, offset):
c = l
for _ in range(offset):
c = next(c)
return c
def next(c):
t = bound(c+1)
while es[t]:
t = bound(t+1)
return t
def bound(v):
return (v % len(es))
n,k = map(int, input().split())
a = list(map(int, input().split()))
l = 0
es = [False]*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 ... | f = lambda: map(int, input().split())
n, k = f()
s = 0
b = list(range(n))
for a in f():
s = (s + a) % len(b)
print(1 + b.pop(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;
struct debugger {
static void call(string::iterator it, string::iterator ed) {}
template <typename T, typename... aT>
static void call(string::iterator it, string::iterator ed, T a, aT&... rest) {
string b;
for (; *it != ','; ++it)
if (*it != ' ') 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 ... | import sys
import bisect
from bisect import bisect_left as lb
input_=lambda: sys.stdin.readline().strip("\r\n")
from math import log
from math import gcd
from math import atan2,acos
from random import randint
sa=lambda :input_()
sb=lambda:int(input_())
sc=lambda:input_().split()
sd=lambda:list(map(int,input_().split())... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.*;
import java.util.*;
public class MainClass
{
public static void main(String[] args)throws IOException
{
Reader in = new Reader();
int n = in.nextInt();
int k = in.nextInt();
int[] A = new int[k];
for (int i=0;i<k;i++) A[i] = in.nextInt();
Arra... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | x = input().split(' ')
y = input().split(' ')
x = list(map(int, x))
y = list(map(int, y))
n = x[0]
child = []
for i in range(n):
child.append(i + 1)
z = []
lead = 1
for i in range(len(y)):
lead = child.index(lead)
if(lead == n):
out = 1
else:
out = lead + 1
t = y[i] % n ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n,k=map(int,raw_input().split())
child=range(1,n+1)
kk=map(int,raw_input().split())
pos=0
for i in range(k):
left=kk[i]%len(child)
x=(pos+left)%len(child)
# print "left "+str(left)
print str(child[x]),
child.pop(x)
# x=(pos+left)%len(child)
# print child
pos=x
# print "position"+str(... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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(s) for s in input().split()]
a=[int(s) for s in input().split()]
b=[i for i in range(1,n+1)]
v=0
rez=[]
for i in range(k):
t=a[i]%len(b)
v+=t
v%=len(b)
rez.append(b[v])
del b[v]
print(' '.join([str(elem) for elem in rez])) |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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/python3
import sys
n, k = map(int, sys.stdin.readline().split())
a = [int(x) for x in sys.stdin.readline().split()]
l = [i for i in range(1, n + 1)]
p = 0
ret = []
for d in a:
p += d
p %= len(l)
ret.append(l[p])
del l[p]
print(' '.join(str(x) for x in ret))
|
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int a[k], b[n];
for (int i = 1; i <= n; i++) b[i] = i;
for (int i = 0; i < k; i++) cin >> a[i];
int s = 1, tmp, tmp_n;
tmp_n = n;
for (int i = 0; i < k; i++) {
tmp = a[i] % tmp_n;
while (tmp > 0) {
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.util.*;
public class p792b{
public static void main(String args[]){
Scanner in=new Scanner(System.in);
int n=in.nextInt();
LinkedList<Integer> l=new LinkedList<Integer>();
for(int i=0;i<n;i++){
l.add(i+1);
}
int k=in.nextInt();
int leader=0;
for(int i=0;i<k;i++){
int c=in.nextInt();
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class CFE18B {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader bf = new BufferedReader(new InputStreamRe... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 P792B {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int a[105];
vector<int> v;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, k;
cin >> n >> k;
for (int i = 0; i < k; i++) cin >> a[i];
for (int i = 1; i <= n; i++) v.push_back(i);
int ptr = 0;
for (int i = 0; i < k; i++) {
int x = a[i... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int n, k;
int arr[110], a[110];
int main() {
int i, j;
cin >> n >> k;
for (i = 1; i <= n; i++) arr[i] = i;
for (j = 0; j < k; j++) {
cin >> a[j];
}
i = 1;
int c, t;
for (j = 0; j < k; j++) {
c = (i + a[j]) % n;
if (c == 0) c = n;
cout << 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;
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
long long power(unsigned long long a, unsigned ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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);
int n, k;
cin >> n >> k;
int a[n], b[k];
for (int i = 0; i < n; i++) {
a[i] = i + 1;
}
for (int j = 0; j < k; j++) {
cin >> b[j];
}
int leader = 0;
for (int j = 0; j < k; j++) {
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
vector<int> s;
int n, k, a, p;
int main() {
cin >> n >> k;
for (int x = 1; x <= n; x++) s.push_back(x);
while (k--) {
cin >> a, p = (p + a) % s.size();
cout << s[p] << " ", s.erase(s.begin() + 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 ... | import java.util.LinkedList;
import java.util.Scanner;
public class App {
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
int n = inp.nextInt();
int k = inp.nextInt();
int[] arr = new int[k];
for (int i = 0; i < k; i++) {
arr[i] = inp.nextInt();
}
int lp = 0, tn, tmp, ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 I {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int num=sc.nextInt();
ArrayList<Integer>peers=new ArrayList<Integer>();
int step=sc.nextInt();
int[]res=new int[step];
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 ... | #include <bits/stdc++.h>
using namespace std;
const int N = (1e6 + 12);
const int mod = (1e9 + 7);
const int inf = (1e9 + 7);
int a[N];
vector<int> v, ans;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
cin >> a[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>
double pi = acos(-1.0);
using namespace std;
int n, k, pos;
long long a;
int vis[105];
int main() {
memset(vis, 0, sizeof(vis));
cin >> n >> k;
int num = n;
pos = 1;
for (int i = 0; i < k; i++) {
cin >> a;
int ans = a % num;
if (ans == 0) {
if (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;
int a[110];
int main() {
int n, k;
cin >> n >> k;
for (int i = 0; i < n; i++) {
a[i] = i + 1;
}
int pos = 0;
for (int i = 0; i < k; i++) {
int tmp;
cin >> tmp;
pos = (pos + tmp) % n;
cout << a[pos] << " ";
for (int i = pos; 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 a[110];
int main() {
int n, m;
cin >> n >> m;
vector<int> v;
for (int i = 0; i < n; i++) {
v.push_back(i + 1);
}
for (int i = 0; i < m; i++) {
cin >> a[i];
}
int lea = 0;
for (int i = 0; i < m; i++) {
lea = (lea + a[i]) % v.size();
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;
int a[105];
map<int, bool> q;
int main() {
while (~scanf("%d %d", &n, &k)) {
q.clear();
for (int i = 0; i < k; i++) scanf("%d", &a[i]);
int t = 1;
int t2 = n;
for (int i = 0; i < k; i++) {
int t3 = (a[i] %= t2);
while (t3--) {
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
c = range(1, n + 1)
l = 0
for i in range(k):
index = (l + a[i] % n) % n
print c[index],
del c[index]
n -= 1
l = 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 ... | import java.util.*;
public class Elimilate {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
String nums = scanner.nextLine();
int num1 = Integer.parseInt(nums.substring(0, nums.lastIndexOf(" ")));
int num2 = Integer.parseInt(nums.substring(nums.lastIndexOf(" ")+1));
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 ... | #include <bits/stdc++.h>
const int pi = acos(-1);
using namespace std;
int n, k;
vector<int> v, u;
int main() {
cin >> k >> n;
v.resize(k);
u.resize(n);
for (int i = 0; i < k; i++) v[i] = i + 1;
for (int i = 0; i < n; i++) cin >> u[i];
int leader = 0;
int i = 0;
while (n--) {
int lel = u[i] % v.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 ... | #include <bits/stdc++.h>
using namespace std;
long long int min(long long int a, long long int b) { return a < b ? a : b; }
long long int min(long long int a, long long int b, long long int c) {
a = min(a, b);
a = min(a, c);
return a;
}
long long int max(long long int a, long long int b) { return a > b ? a : 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 main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int n, k, x;
cin >> n >> k;
long long int i, l = 0, m = n, j, y, r;
vector<int> v(n);
for (i = 0; i < n; i++) v[i] = i + 1;
for (i = 0; i < k; i++) {
cin >> x;
y = (l + x) % m;
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, a, c = 0;
vector<int> v;
cin >> n >> k;
for (int i = 0; i < n; i++) v.push_back(i + 1);
while (k--) {
cin >> a;
c = (c + a) % v.size();
cout << v[c] << ' ';
v.erase(v.begin() + c);
}
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 ... | #include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long llinf = 0x3f3f3f3f3f3f3f3f;
const int maxn = 3e5 + 5;
const int mod = 1e9 + 7;
const double eps = 1e-5;
int a[105];
int vis[maxn], ans[maxn];
int main() {
int n, k;
while (~scanf("%d%d", &n, &k)) {
memset(vis, 0, sizeof(vi... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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[200];
bool live[200];
int main() {
memset(live, true, sizeof(live));
cin >> n >> k;
for (int i = 0; i < k; i++) cin >> a[i];
int L = 0;
for (int i = 0; i < k; i++) {
int sh = (a[i]) % (n - i);
if (sh == 0) sh = n - i;
int cnt = 0;
i... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
const int N = 111;
int pre[N], nnext[N];
int main() {
int n, m, num, first;
int last, Next;
int i, j;
cin >> n >> m;
pre[1] = n, nnext[1] = 2;
for (i = 2; i <= n; i++) {
pre[i] = i - 1;
nnext[i] = i + 1;
}
nnext[n] = 1;
first = 1;
while (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.math.BigInteger;
import java.io.*;
import java.util.*;
import java.lang.*;
public class Q2 {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
static long MOD = 1000000007;
public static void ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 arr[102];
for (int i = 1; i <= n; i++) {
arr[i] = 1;
}
int next = 1;
int val;
int count = 0;
vector<int> vi;
while (k--) {
cin >> val;
val = val % (n - count) + 1;
while (true) {
if (arr[nex... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | n, k = map(int, input().split())
t = list(range(n))
i = 0
for ai in map(int, input().split()):
i = (i + ai) % len(t)
print(t[i] + 1, end = ' ')
t = t[: i] + t[i + 1:]
i = i % len(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 java.io.*;
import java.util.*;
import java.awt.*;
public class edu18B
{
BufferedReader in;
PrintWriter ob;
StringTokenizer st;
public static void main(String[] args) throws IOException {
new edu18B().run();
}
void run() throws IOException {
in=new BufferedReader(new InputStreamReader(System.in));
ob=... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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()]
A = [int(x) for x in stdin.readline().rstrip().split()]
X = []
for i in range(N):
X.append(i+1)
L = 0
E = []
for i in range(len(A)):
P = (L+A[i])%len(X)
L = P
E.append(str(X[P]))
X.remove(X[P])
print ' '.j... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;
/**
* Built using CHel... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.util.*;
public class Counting_out_Rhyme {
public static void main(String args[]){
Scanner in=new Scanner(System.in);
int childrens=in.nextInt();
ArrayList<Integer> children_array=new ArrayList<Integer>();
ArrayList<Integer> eliminated_children=new ArrayList<Integer>();
for(int i=1;i<=childrens;i++)
childr... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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()))
an = [i+1 for i in range(n)]
result = []
j = 0
for i in range(k):
j += a[i] % len(an)
if j >= len(an):
j -= len(an)
result.append(an[j])
an.pop(j)
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, t = 0;
cin >> n >> k;
vector<int> v(n);
for (int i = 0; i < n; i++) v[i] = i + 1;
for (int i = 1; i <= k; i++) {
int nr;
cin >> nr;
t = (t + nr) % v.size();
cout << v[t] << " ";
v.erase(v.begin() + t);
}
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 ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int temp;
vector<int> persons;
vector<int>::iterator it;
for (int i = 1; i <= n; i++) persons.push_back(i);
int leader = 0;
while (k--) {
cin >> temp;
temp = temp % n;
cout << persons[(leader + temp) % 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.sql.Array;
import java.util.*;
public class Main {
private static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int n = sc.nextInt();
int k = sc.nextInt();
int[] array = new int[k];
for(int i = 0; i < k; i++){
array[i]... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, k, i, j;
cin >> n >> k;
long long int a[k];
long long int b[n];
long long int c1[n];
for (i = 0; i <= n - 1; i++) {
b[i] = -1;
}
for (i = 0; i <= n - 1; i++) {
c1[i] = -1;
}
for (i = 0; i <= k - 1; i++) {
cin >> ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 code;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.OutputStreamWriter;
import java.util.*;
public class B {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int k = scan.nextInt();
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;
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);
long long pos = 0;
for (long ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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;
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:256000000")
FILE *stream;
const int INF = 1e9 + 7;
const long long INFL = (long long)1e18 + 1;
const int SIZE = 2e5 + 10;
const int TSIZE = 1e3 + 10;
const long double eps = 0.000001;
const long long MOD = 1e9 ... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.StringTokenizer;
public class Test
{
... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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()))
children = [x for x in range(1,n+1)]
l_index = 0
i = 0
out = []
while i < k:
pos = (a[i] % len(children)) + l_index
elim = children[pos % len(children)]
out.append(str(elim))
i += 1
l_index = pos % len(children)
del children[pos%len(childr... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 {
static int t,n,m,k,mod=998244353,maxn=300005;
static long INF=(long)1e16;
void solve(PrintWriter out, Reader in) throws IOException{
n = in.nextInt();
k = in.nextInt();
int[] arr = new int[k];
for(int i=0;... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | #include <bits/stdc++.h>
using namespace std;
long long int arr[105];
void del(long long int p, long long int n) {
for (int i = p; i <= n - 1; i++) {
arr[i] = arr[i + 1];
}
}
int main() {
long long int n, k;
cin >> n >> k;
vector<long long int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[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=(input().split(" "))
n,k=int(n),int(k)
a=list(range(1,n+1))
l=0
for i in input().split(" "):
e=((l+int(i))%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 ... | #####################################
import atexit, io, sys, collections, math, heapq, fractions
buffer = io.BytesIO()
sys.stdout = buffer
@atexit.register
def write(): sys.__stdout__.write(buffer.getvalue())
#####################################
n,k = map(int, raw_input().split())
ais = map(int, raw_input().split... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;
/**
* Built using CHel... |
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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, steps = map(int, input().strip().split())
numbers = list(map(int, input().strip().split()))
children = list(range(0, n_children))
leader = 0
#print('leader = 0')
#print(children)
#print(numbers)
for step in range(0, steps):
eliminated = (leader + numbers[step]) % len(children)
print(children[elimi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.