prompt
string
response
string
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.*; import java.util.*; public class Main { InputReader scn; PrintWriter out; String INPUT = ""; void solve() { int n = scn.nextInt(), k = scn.nextInt(), x = scn.nextInt(); int[] fr = new int[1 << 10]; for (int i = 0; i < n; i++) { int z = scn.nextInt(); fr[z]++; } for(int i = 1; i ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; const int N = 1024; int A[N], T[N]; int n, k, x; void solve() { cin >> n >> k >> x; int v; for (int i = 0; i < n; i++) { cin >> v; A[v]++; } for (int t = 0; t < k; t++) { fill(T, T + N, 0); int cnt = 0; for (int i = 0; i < N; i++) { if (A...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.util.Scanner; /** * Created by DQ-PC on 22.02.2017. */ public class CFavoriteNumber { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int x = in.nextInt(); int[] a = new int[1025]; ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; int a[2][1 << 10]; int main() { std::ios_base::sync_with_stdio(false); int n, k, first, f = 0; cin >> n >> k >> first; for (int i = 0; i < int(n); i++) { int s; cin >> s; a[f][s]++; } for (int t = 0; t < int(k); t++) { int c = 0; for (int i =...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Comp...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
n, k, x = [int(i) for i in input().split()] a = [int(i) for i in input().split()] p1, i = [], 0 while i < k: a.sort() p1 = a.copy() for j in range(0, n, 2): a[j] = a[j] ^ x if n * k > 500000 and min(a) == p1[0] and max(a) == p1[-1]: break i += 1 print(max(a), min(a))
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
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.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Stri...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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; set<int> st; vector<int> v; for (int i = 0; i < n; i++) v.push_back(i); int lead = 0; for (int i = 0; i < k; i++) { int x; cin >> x; n = v.size(); x %= n; int tmp = (lead + x) % n; cout << v[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 ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, num, in = 0; vector<long long> v; cin >> n >> k; for (int i = 0; i < n; i++) { v.push_back(i + 1); } while (k--) { cin >> num; num = num % v.size(); if (num > v.size() - in) { cout << v[num - v.size() + 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,y=input().split() n=int(n) y=int(y) liste=list(range(1,n+1)) x=0 z=0 liste2=list(map(int,input().split())) while x<y: z=((z+liste2[x])%len(liste)) print(liste[z]) liste.pop(z) x+=1
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
# coding=utf-8 __author__ = 'Alexander' s = input() n, k = tuple(map(int, s.split())) s = input() a = list(map(int, s.split())) r = list(range(1, n+1)) j = 0 for i in range(k): j = (j + a[i]) % n n -= 1 print(r[j], end=' ') del r[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 ...
n,k=map(int,input().split()) a=list(map(int,input().split())) b=[i+1 for i in range(n)] l=1 for i in range(k): for j in range(len(b)): if b[j]==l: break r=len(b)-j-1 l=j+1 t=a[i]%(l+r) if t<=r and t!=0: t=j+t elif t>r: t=(t-r)-1 else: t=j if 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 ...
n, k = map(int, input().split()) *a, = map(int, input().split()) ans = [] peo = list(range(1, n+1)) cur = 0 for i in range(k): dind = (cur+a[i])%len(peo) cur = dind ans.append(peo.pop(dind)) cur %= len(peo) dind %= len(peo) 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()) circle = range(1, n+1) a = map(int, raw_input().split()) leader = 0 for i in xrange(k): tmp = (a[i] + leader) % (len(circle)) print circle[tmp], del circle[tmp] leader = tmp % len(circle)
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
#include <bits/stdc++.h> using namespace std; void FastIO() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const int N = 1e5; int main() { FastIO(); int tc, ca = 0; int n, k; cin >> n >> k; vector<int> c; for (int i = 1; i <= n; i++) { c.push_back(i); } int in; int cur = 0; 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.util.Scanner; import java.util.ArrayList; public class CodeF { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int k=sc.nextInt(); int a[]=new int[k]; for(int i=0;i<k;i++) { a[i]=sc.nextInt(); } ArrayList<Integer> list=new ArrayList<Integ...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
a=[] n,m=map(int,raw_input().split()) for i in range(n): a.append(i+1) h=0 s=raw_input().split() b=[0]*m for j in range(m): b[j]=int(s[j]) for i in range(m): # print (h+b[i])%len(a) h = (h + b[i]) % len(a) print a[h], del a[h]
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc =new Scanner(System.in); int n =sc.nextInt(); int k=sc.nextInt(); int [] ai = new int [k]; int [] e =new int [k]; for(int i=0;i<k;i++) { ai[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())) children = list(range(1,n+1)) lea, idx = 0, 0 for ai in a: idx = (lea+ai)%len(children) print(children.pop(idx)) lea = 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 ...
temp=input() (n,k)=temp.split(" ") n=int(n) k=int(k) temp=input() tab=temp.split(" ") tab=[int(x) for x in tab] i=0 players=[] while i<n : players.append(i+1) i+=1 idx=0 i=0 while(i<k): idx+=tab[i] idx%=len(players) print(players[idx],end=" ") idx%=len(players) del players[idx] 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 main() { cin >> n >> k; vector<int> v; for (int i = 0; i < n; i++) { v.push_back(i + 1); } for (int p = 0; p < k; p++) { int position; cin >> position; position %= int(v.size()); if (p > 0) cout << " "; cout << v[position]; ...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
n,k=map(int,input().split()) ks=list(map(int,input().split())) a=[] for i in range(1,n+1): a.append(i) l=0 for i in range(k): t=ks[i] l=(t+l)%n print(a.pop(l),end=" ") n-=1
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
import sys input = raw_input def solve(): ans = list() n, k = map(int, input().split()) a = list(map(int, input().split())) cur = [i + 1 for i in range(n)] idx = 0 for move in range(k): idx = (idx + a[move]) % len(cur) ans.append(cur[idx]) del cur[idx] if idx >= len(cur): idx = 0 print " ".join(map(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 sys #sys.stdin = open('in', 'r') #n = int(input()) #a = [int(x) for x in input().split()] n,k = map(int, input().split()) cs = [i + 1 for i in range(n)] rem = 0 for v in map(int, input().split()): rem = (rem + v) % len(cs) print(cs[rem], end=' ') cs.remove(cs[rem])
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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()) k = list(map(int , input().split())) l, ans = [], [] for i in range(n): l.append(i) leader=0 for i in k: ans.append( l[((leader+i)%(len(l)))] +1) leader = ((leader+i)%(len(l))); l.remove(ans[-1]-1) leader = leader%len(l) print(*ans, sep=" ")
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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()) cs = list(range(1, n+1)) l = 0 res = "" len = n for x in a: pos = (l + x) % len #print(cs, pos) res += str(cs[pos]) + " " del cs[pos] len -= 1 l = pos print(res)
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
import java.util.*; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in=new Scanner(System.in); int n=in.nextInt(); ArrayList<String> a=new ArrayList<>(); for(int i=0;i<n;i++) { a.add(i+1+""); } int k=in.nextInt(); int s[]=new int[k]; int sit...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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()] b = [x for x in xrange(1, n+1)] start = 0 count = n counter = 0 while(count > 0 and counter<k): index = a[counter]%count c = 0 ans = start while(c!=index): ans = (ans + 1) % n if(b[ans]!=-1): c+=1 print b[ans], b[ans] = ...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
import java.util.*; import java.io.*; public class A { public static void main(String ar[]) throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String s1[]=br.readLine().split(" "); int n=Integer.parseInt(s1[0]); 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 ...
import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.LinkedList; /** * Created by assantoleuov on 12/25/16. */ public class Test { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStream...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
n, k = map(int, input().split()) children = list(range(1, n + 1)) leader = 0 answer = list() for a in map(int, input().split()): leader = (leader + a) % len(children) answer.append(children[leader]) del children[leader] print(*answer)
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
#include <bits/stdc++.h> using namespace std; int main(int argc, char** argv) { int n, k; scanf("%d%d", &n, &k); std::vector<int> a(k); for (int32_t i = 0; i < (k); ++i) scanf("%d", &(a[i])); std::vector<int> children(n); for (int32_t i = 0; i < (n); ++i) { children[i] = i + 1; } int cur = 0; for ...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class B { static class Scanner{ BufferedReader br=null; StringTokenizer tk=null; public Scanner(){ br=new BufferedReader(new InputStreamReader(System.in)); } public 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 ...
import java.util.*; import javax.management.monitor.CounterMonitor; import java.io.*; import java.lang.*; public class B { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next()...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
n,k=(int(n) for n in input().split()) A=[int(n) for n in input().split()] V=[i+1 for i in range(n)] pos=0 elim=[] for i in range(k): pos=(pos+A[i])%len(V) elim.append(V.pop(pos)) if(pos == len(V)): pos=0 for x in elim: print(x,end=' ')
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
#include <bits/stdc++.h> using namespace std; int p, n, k, vet[111]; int main() { for (int(i) = (0); (i) < (111); (i)++) vet[i] = i; scanf("%d%d", &n, &k); for (int(i) = (0); (i) < (k); (i)++) { int v; scanf("%d", &v); p = (p + v) % n; printf("%d%c", vet[p] + 1, i == k - 1 ? '\n' : ' '); 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 ...
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) print str(child[(pos+left)%len(child)]), x = (pos+left)%len(child) y = child[(pos+left+1)%len(child)] child.pop(x) #print child pos=child.index(y) #print "po...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
#include <bits/stdc++.h> using namespace std; set<long long> dv; vector<pair<long long, long long> > prime_dv; const int N = 200000; int main() { int n, k; cin >> n >> k; vector<int> a(k); for (int i = 0; i < k; ++i) cin >> a[i]; int pos = 0; vector<int> child(n); for (int i = 0; i < n; ++i) child[i] = i;...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
n, k = map(int, input().split()) childs = list(range(1, n + 1)) a = list(map(int, input().split())) res = [] main = 0 for i in a: idx = main idx = (idx + i) % len(childs) res.append(childs[idx]) del childs[idx] main = idx print(' '.join(map(str, res)))
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
//package EDU18; import java.util.LinkedList; import java.util.Scanner; public class B { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(), k = sc.nextInt(); LinkedList<Integer> list = new LinkedList<Integer>(); 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 ...
#include <bits/stdc++.h> using namespace std; int n, k, el[101]; set<int> st; int main() { cin >> n >> k; for (int i = 1; i < (int)n + 1; ++i) st.insert(i); set<int>::iterator it = st.begin(), er; for (int i = 0; i < (int)k; ++i) { int a; cin >> a; int ind = ((a) % (int)(st).size()); for (; ind-...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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> vt; scanf(" %d %d", &n, &k); int a, l = 0; for (int i = 0; i < n; ++i) vt.push_back(i); for (int i = 0; i < k; ++i) { scanf(" %d", &a); int p = (l + a) % n; printf("%d ", vt[p] + 1); vt.erase(vt.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 ...
n, k = [int(x) for x in str(input()).split(' ', 1)] next_ = [i+1 for i in range(n+1)] next_[n] = 1 a = [int(x) for x in str(input()).split(' ')] remain = n cur = 1 prev = None eli = [] for a0 in a: a0 = a0 % remain for _ in range(a0): prev = cur # print("{}->{}".format(cur, next_[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 ...
import java.util.ArrayList; import java.util.List; import java.util.Scanner; import java.util.StringJoiner; /** * Created by dkytsmen on 3/27/17. */ public class Second { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
n, k = map(int, input().split()) a = list(map(int, input().split())) cur = 0 children = [i+1 for i in range(n)] for i in range(k): cur = (cur+a[i])%len(children) print(children[cur],end=' ') children = children[:cur] + children[cur+1:] cur %= len(children)
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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]; for (int i = 0; i < k; i++) { cin >> a[i]; } long long cur = 0; vector<int> v(n); for (int i = 0; i < n; i++) { v[i] = i + 1; } vector<bool> used(n, false); for (int i = 0; i < k; i++) { 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 ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Array; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.Map; imp...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 numbers[110]; int main() { int n, k; scanf("%d%d", &n, &k); int cursor = 1; for (int i = 0; i < k; i++) { int tmp; scanf("%d", &tmp); tmp %= n - i; while (tmp--) { while (true) { cursor += 1; cursor %= n; if (numbers...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 bisect from itertools import accumulate import os import sys import math from decimal import * from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in fi...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); long[] arr = new long[k]; for (int i = 0; i < k; i++) { arr[i] = sc.nextLong(); } Lin...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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()) s, a, v, c = list(range(1, n + 1)), list(map(int, input().split())), [], 0 for i in range(k): c = (c + a[i]) % len(s) v.append(str(s.pop(c))) print(' '.join(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 ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; 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 ...
from math import * n, k = map(int, input().split()) q = [int(i) for i in input().split()] v = [i for i in range(n)] x = 0 for i in range(k): # print(v) x = (x + q[i]) % len(v) print(v[x] + 1, end=" ") v.pop(x) 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 ...
num, num_step = map(int,raw_input().split()) step = map(int,raw_input().split()) child = [] for i in range(1, num + 1): child.append(i) ans = [] start = 0 for each in step: count = len(child) temp = child.pop((each + start) % count) ans.append(temp) start = (each + start) % count if start > len(...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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.math.RoundingMode; import java.text.DecimalFormat; import java.util.*; import java.util.InputMismatchException; public class Solution { public static void main(String[] args){ InputReader in=new InputReader(System.in); PrintWriter pw=new PrintWriter(System....
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
n, k = map(int, raw_input().split()) child = [] for i in xrange(n): child.append(i+1) a = map(int, raw_input().split()) ini = 0 for i in xrange(k): print child[(a[i] + ini)%len(child)], #print child ini = (a[i] + ini)%len(child) del child[ini]
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
n,k=map(int,input().split()) list_k=list(map(int,input().split())) list_child=[None]*n for i in range(n): list_child[i]=i count_from=1 for i in range(k): eliminate=(list_k[i]+count_from-1)%len(list_child) print(list_child.pop(eliminate)+1,end=" ") count_from=(eliminate+2)%len(list_child) count_from-=1
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
n, k = map(int, raw_input().split(' ')) a = map(int, raw_input().split(' ')) c = [] for i in range(n): c.append(i + 1) res = [] start = 0 for i in range(k): pos = (start + a[i] % (n - i)) % (n - i) res.append(c[pos]) start = pos % (n - i - 1) c.remove(c[pos]) print ' '.join(map(str, res))
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.InputMismatchException; import java.util.LinkedList; public class CountingOutRhyme { public static void main(Strin...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
n, k = [int(i) for i in raw_input().split()] a=[] for i in xrange(1, n+1): a.append(i) b = map(int, raw_input().split()) leader = 1 for i in b: ele = (i+leader)%len(a) x= (a.pop(ele)-1) if x==0: x=n print x, leader = ele
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 + 5; int num[200]; int main() { int n, K; scanf("%d%d", &n, &K); for (int i = 1; i <= K; i++) scanf("%d", &num[i]); vector<int> v(n); iota(v.begin(), v.end(), 1); int p = 0; for (int i = 1; i <= K; i++) { p = (p + num[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 ...
def circle(arr, start): if start == arr.__len__(): start = 0 while True: yield start start += 1 if start == arr.__len__(): start = 0 def get_ith_victim(a, i, count): z = count % a.__len__() it = circle(a, i) toPop = i while z >= 0: toPop...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
n,k = map(int, raw_input().split()) a = map(int, raw_input().split()) elim = [False for i in range(n)] curnum = 0 for i in range(k): step = a[i] % (n - i) while step > 0: if not elim[curnum]: step -= 1 curnum = (curnum + 1) % n while elim[curnum]: curnum = (curnum + 1) % n elim[curnum] = True print curnum...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 main(): n, k = map(int, input().split()) a = map(int, input().split()) kids = list(range(1, n + 1)) i = 0 for ai in a: i += ai i %= len(kids) print(kids[i], end=' ') del kids[i] if __name__ == '__main__': # import sys # sys.stdin = open("B.txt") ma...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
#include <bits/stdc++.h> int main() { int n, k, a; bool f[105]; scanf("%d %d", &n, &k); memset(f, false, sizeof(f)); int in = 0; for (int i = 0; i < k; i++) { scanf("%d", &a); for (int j = a % (n - i); j > 0; j--) { do { in = (in + 1) % n; } while (f[in]); } f[in] = 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 n, k; int cnt, p; bool vis[105]; void solve(int x) { int tmp = x % cnt; if (tmp == 0) tmp += cnt; do { p = (p + 1) % n; while (vis[p]) p = (p + 1) % n; tmp--; } while (tmp); vis[p] = 1; cout << p + 1 << endl; while (cnt != 0 && vis[p]) p = (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.ArrayList; import java.util.Scanner; public class B792 { public static void main(String... xxx){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); ArrayList<Integer> a=new ArrayList<Integer>(n); for(int j=0;j<n;j++) ...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
n, k = map(int, input().split()) a = list(map(int, input().split())) deleted = [] for i in range(n): deleted.append(i) host = 0 for i in range(k): j = (host + a[i]) % n print(deleted.pop(j) + 1, end=' ') if j == n - 1: host = 0 else: host = j 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 ...
from collections import deque N, K = map(int, input().split()) A = list(map(int, input().split())) q = deque(range(1, N+1)) ret = [] for k in range(K): for a in range(A[k]%len(q)): q.append(q.popleft()) ret.append(q.popleft()) print(' '.join([str(r)for r 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 ...
x,y=map(int,input().split()) arr1=[] arr3=[] arr=list(map(int,input().split())) l=1 arr1=[0]*x for i in range(0,x): arr1[i]=i+1 for i in range(0,len(arr)): x1=(arr[i]+l)%x if x1==0: x1=x arr3.append(arr1[x1-1]) del arr1[x1-1] x-=1 l=x1 for i in range(0,len(arr3)): print(arr3[i],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 ...
#include <bits/stdc++.h> using namespace std; int n, k, x = 0; int mas; 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++) { scanf("%d", &mas); x = (x + mas) % n; cout << v[x] << " "; v.erase(v.begin() + x); 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 ...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 105; int a[MAX_N]; 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]; } queue<int> q; for (int i = 1; i <= n; i++) { q.push(i); } int cnt = n; for ...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
import java.io.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.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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()) n1 = [x for x in range(1,n+1)] l = 0 for i in range(k): ste = a[i] r = ste%len(n1); if l+r>len(n1)-1: pos = l+r-len(n1) if pos==len(n1)-1: l = 0 else: l = pos else: pos = l+r l = pos p = n1.pop(pos) print p,
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
#include <bits/stdc++.h> using namespace std; deque<int> pp; int main() { long long n, k; cin >> n >> k; for (long long i = 1; i <= n; i++) { pp.push_back(i); } for (long long i = 1; i <= k; i++) { long long kk; cin >> kk; kk %= pp.size(); while (kk--) { pp.push_back(pp.front()); ...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
import java.util.*; public class B { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int k = input.nextInt(); List<Integer> ppl = new ArrayList<Integer>(n); int leader = 0; for (int i = 0; i < n; ++i) ppl.add(i); 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 ...
#include <bits/stdc++.h> using namespace std; template <class T> inline T lcm(T a, T b) { if (a < 0) return lcm(-a, b); if (b < 0) return lcm(a, -b); return a * (b / (gcd(a, b))); } template <class T> inline T gcd(T a, T b) { if (a < 0) return gcd(-a, b); if (b < 0) return gcd(a, -b); return (b == 0) ? 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 ...
// template : secondThread import java.io.*; import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class main2 { public static void main(String[] args) { try { PrintWriter fop = new PrintWriter(System.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 ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class testtest2 { public testtest2() { } public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader reader = new BufferedReader(new InputStrea...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class codeforces implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
class object_1(): def __init__(self,n,next): self.number = n self.next = None self.previous = None def get_next(self,n1): self.next = n1 class linkedList(): def __init__(self,length,k,list_k): self.length = length self.k = k self.list_k = list_k self.temp_list = [] def form_the_list(self): ...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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]
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 solve(): n, k = [int(x) for x in input().split(' ')] a = [int(x) for x in input().split(' ')] curr = [i for i in range(n)] i = 0 j = 0 ans = [] for c in range(k): i = (i + a[j]) % n ans.append(curr[i] + 1) del curr[i] n -= 1 i = i % n j += ...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(k); for (int i = 0; i < k; i++) cin >> a[i]; vector<int> v(n); iota(v.begin(), v.end(), 1); int z = 0; int mem = 0; while (z != k) { cout << *(v.begin() + (a[z] + mem) % (n - z)) << " "; v.erase(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> void debug() {} int n, k; int main() { scanf("%d %d", &n, &k); std::list<int> li; for (int i = 1; i <= n; ++i) { li.push_back(i); } int leader = 0; for (int i = 1; i <= k; ++i) { int x; scanf("%d", &x); int step = x % li.size(); leader = (leader + step) % li.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 sys n, k = map(int,sys.stdin.readline().strip().split(" ")) steps = map(int, sys.stdin.readline().strip().split(" ")) childrens = [x for x in xrange(1, n + 1)] leaderPos = 0; pos = 0 for i in steps: pos = (i+leaderPos) % n print childrens.pop(pos), leaderPos = pos n -= 1
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 105; vector<int> v; int n, k; int step; int a[MAX_N]; int main() { cin >> n >> k; int led = 1; v.push_back(n); for (int i = 1; i < n; ++i) { v.push_back(i); } for (int i = 0; i < k; i++) { cin >> step; led += step; led %= 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 ...
def solve(n, k, ks): res = [] ns = range(1, n + 1) for i in xrange(k): n = len(ns) a = (ks[i]) % n res.append(ns[a]) ns = ns[a + 1:] + ns[:a] return res assert solve(7, 5, [10, 4, 11, 4, 1]) == [4, 2, 5, 6, 1] assert solve(3, 2, [2, 5]) == [3, 2] if __name__ == '__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 ...
# Codeforces # Educational Codeforces Round 18 # MichelJ # B. Counting-out Rhyme def solve(a, n, k): children = range(n) leader = 0 elims = [] for i in xrange(k): elim = (leader + a[i]) % n elims.append(children.pop(elim) + 1) n -= 1 leader = elim % n return elims d...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
from copy import deepcopy as dcopy def main(): n, k = map(int, input().split()) ks = list(map(int, input().split())) children = list(range(n)) leader_i = 0 res = [] for k in ks: elim_i = (leader_i + k) % len(children) elim_num = dcopy(children[elim_i]) nextl_i = (leader_...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
n, k = map(int, input().strip().split()) a = list(map(int, input().strip().split())) ch = list(range(1, n + 1)) curr = 0 out = [] for i in range(k): curr = (curr + a[i]) % len(ch) out.append(ch.pop(curr)) if curr == len(ch): curr = 0 print(' '.join(map(str, out)))
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
n,k = map(int,raw_input().split(' ') ) a = list(map(int,raw_input().split(' ') )) kp = list() for i in range(1,n+1): kp.append(i) ld = 0 tmp = n for i in range(0,k): a[i] = a[i]%tmp print kp[(ld+a[i] )%tmp], kp.remove(kp[ (ld+a[i] )%tmp ] ) ld = (ld+a[i])%tmp tmp-=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()] ass = [int(i) for i in input().split()] chi = [i+1 for i in range(n)] s = 0 for a in ass: print(chi[(a+s)%n], end=" ") chi.pop((a + s) % n) s = (a+s)%n n -= 1
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
import java.util.*; import java.io.*; import java.lang.*; public class Code2 { static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 vis[105]; int main() { int n, k, l, x, y = 0, cnt = 0, steps = 0; cin >> n >> k; l = 0; y = 0; while (k--) { cin >> x; cnt = 0; steps = x % (n - l); while (cnt < steps) { if (vis[y]) { y++; y %= n; continue; ...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
#include <bits/stdc++.h> using namespace std; template <class X, class Y> void minimize(X &x, const Y &y) { if (x > y) x = y; } template <class X, class Y> void maximize(X &x, const Y &y) { if (x < y) x = y; } template <class T> T Abs(const T &x) { return (x < 0 ? -x : x); } void process(void) { int n, q; sca...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 living[102]; int arr[102]; int main() { int n, k; cin >> n >> k; for (int i = 0; i < k; i++) cin >> arr[i]; int remain = n; int currentLeader = 1; for (int i = 0; i < k; i++) { int toMove = (arr[i] % remain); int index = currentLeader + 1; if (to...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is 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 x, m, n, step = 0, v[1000] = {0}, i, ind = 1, d, j; cin >> m >> n; for (i = 0; i < n; i++) { cin >> x; d = m - i; x = x % d; if (x == 0) { x = d; } for (j = ind + 1; j <= m; j++) { if (!v[j]) x--; if (x == 0) ...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int a[k], b[n]; for (int i = 0; i < k; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { b[i] = i; } int d = 1; for (int i = 0; i < k; i++) { d = (d + a[i]) % n; if (d == 0) d = n; cout << b[d] <...
Problem: n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The ...
n, k = map(int, raw_input().split(' ')) op = map(int, raw_input().split(' ')) start = 0; ans = [] a = [x for x in xrange(1, n + 1)] for i in xrange(k): if op[i] > n: op[i] %= n; start += op[i]; if start >= n: start -= n ans.append(a[start]) n -= 1 a.remove(a[start]) print ' '.join(map(str, ans))