prompt string | response string |
|---|---|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n,m=map(int,input().split())
t=m%(int(n*(n+1)/2))
for j in range (1,n+1):
if t>=j:
t=t-j
else:
print(t)
break
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n,m=map(int,input().split())
c=0
while True :
for i in range(1,n+1) :
if m-i>=0 :
m=m-i
else :
c=1
break
if c==1 :
break
print(m)
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n,m=map(int,input().split())
i=1
while True:
if m>=(i%n):
z=m-i
if z>=0:
m=z
else:
break
else:
break
i+=1
i=(i%(n+1))
if i==0:
i=1
#print(i,m)
print(m) |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n, m = map(int, input().split(' '))
circle_cost = int(n * (n + 1) / 2)
m = m % circle_cost
for i in range(1, n + 1):
if m < i:
break
m -= i
print(m) |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | from math import floor
def array(arr, struc):
return (list(map(struc, arr.split())))
def fullRound(x):
return x * (x + 1) // 2
arr = array(input(), int)
walrus = arr[0]
chips = arr[1]
chips = chips % fullRound(walrus)
lastWalrus = floor(-0.5 + ((8 * chips + 1)/4) ** 0.5)
print(chips - fullRound(lastWa... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, i;
cin >> n >> m;
while (m >= i) {
m -= i;
i++;
if (i == n + 1) i = 1;
}
cout << m;
return 0;
}
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | from functools import reduce
n,m=map(int,input().split())
a=reduce(lambda x,y:x+y,[i for i in range(1,n+1)])
x=m%a
if(x==0):
print(0)
else:
for i in range(1,n+1):
if(x>=i):
x-=i
else:
print(x)
break |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int s = 0;
for (int k = 1; s <= m; k++)
for (int k = 1; k <= n; k++) {
s = s + k;
if (s > m) {
s = s - m;
s = k - s;
cout << s;
return 0;
}
}
return 0;
}
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n, m = tuple(raw_input().split())
n = int(n)
m = int(m)
a = range(1,n+1)
s = 0
while m > 0:
for i in a:
if m < i:
s = m
break
else:
m -= i
if s:
break
print s |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
int main() {
long long n, m, i;
scanf("%I64d %I64d", &n, &m);
i = 1;
while (i <= n) {
if (m >= i) {
m = m - i;
} else {
printf("%I64d", m);
break;
}
i = i + 1;
if (i == n + 1) {
i = 1;
}
}
}
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
while (true) {
for (int i = 1; i <= n; i++) {
if (i > m || !m)
goto out;
else {
m -= i;
}
}
}
out:
cout << m << endl;
return 0;
}
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | inputs = tuple(map(lambda x: int(x), input().split()))
n = inputs[0]
m = inputs[1]
if n == 0:
print(m)
else:
summery = (1 + n) * n / 2
last = m % summery
i = 1
while last >= 0:
last -= i
i += 1
last = int(last + i -1)
print(last)
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n,m = list(map(int,input().split())) #50,1e4
cc = (n*(n+1))//2
m = m%cc
cl = [((i+1)*(i+2))//2 for i in range(n)]
for i in range(1,n+1):
if m >= i:
m -= i
else:
print(m)
break
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, m;
cin >> m >> n;
n = (n % ((m * (m + 1)) / 2));
if (n == 0) {
cout << 0;
return 0;
}
for (int i = 1; i <= m; i++) {
if (n >= i)
n -= i;
else
break;
}
cout << n;
return 0;
}
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n,m=map(int,input().split())
z=1
while m>=z:
m-=z
if z==n:
z=1
else:
z+=1
print(m)
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, c = 0, r = 0, b = 0;
cin >> n >> m;
while (r <= m) {
b += c;
if (c == n) {
c = 0;
}
c++;
r += c;
}
cout << m - b << endl;
return 0;
}
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | x,y = map(int,input().split())
sum2 = 0
i = 1
while y - sum2 >= 0:
if i == x+1:
i = 1
if y - sum2 < i:
break
sum2 = sum2 + i
i = i + 1
print(y-sum2) |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | (n, m) = map(int, raw_input().split())
tot = (1 + n) * n / 2
m %= tot
for i in xrange(1, n+1):
if m < i:
print m
break
m -= i |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | x,y=map(int,raw_input().split(' '))
total=(1+x)*x/2
tmp=y%total
for i in range(x):
if tmp-i>=0:
tmp=tmp-i
else:
break
print tmp
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n, k = map(int, input().split())
sum = ((1+n)*n)//2
if k >= sum:
k %= sum
for i in range(n, -1, -1):
l = ((i+1)*i)//2
if l<=k:
print(abs(k-l))
break
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String s = in.readLine()... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* @author Ivan Reyes, nicolas Patarroyo
*/
public class Main {
public static void main(String[] args) {
Scanner in =... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n,chips=map(int,input().split())
x=(n*(n+1))//2
#print(x)
if(chips>x):
chips=chips%x
for i in range(1,n+1):
if(i>chips):
break
else:
chips-=i
print(chips)
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class _92_A implements Runnable{
public static void main(String[] args) {
new Thread(null, new _92_A(),"Main",1<<27).start();
}
@Override
... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n,m = map(int,input().split())
ans = 0
g = 0
count = 0
e = 0
sum = 0
i = 0
for i in range (1,n+1,1):
ans +=i
if m > ans :
g = m // ans
o = m - g*ans
for u in range(1, o+1, 1):
sum += u
count += 1
if sum > o :
break
for v in range(1, count, 1):
e += v
if count == 1:
i = 1
if e ==... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.util.Scanner;
public class Chips {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int sum=m;
for(int i=1;;i++)
{if(i>n)
i=1;
if(sum-i>=0)
sum-=i;
else break;
}
System.out.println(... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.util.Scanner;
public class ICPC8 {
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int m = s.nextInt();
boolean done = false;
while(!done)
{
for(int i=1;i<=n;i++)
... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
string n;
int main() {
int n, c, i;
cin >> n >> c;
for (i = 1;; ++i) {
if (i > n) i = 1;
if (c < i)
break;
else
c -= i;
}
cout << c;
return 0;
}
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n,m = map(int,input().split())
k = (n*(n+1))//2
k = m%k
for i in range(1,n+1):
if k-i < 0:
break
k-=i
print(k)
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
/**
*
* @au... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int w, t;
cin >> w >> t;
while (true)
for (int i = 0; i < w + 1; i++)
if (t >= i)
t -= i;
else {
cout << t;
return 0;
}
return 0;
}
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int cur = 1;
while (cur <= m) {
m -= cur;
cur = (cur % n) + 1;
}
cout << m << endl;
return 0;
}
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | a,b=map(int,input().split())
i=1
while (b>=0 and i<=a):
if b-i>=0:
b=b-i
else:
break
i+=1
if i>a:
i=0
print(b)
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n, c = [int(x) for x in input().split()]
while n*(n+1)/2 <= c:
c -= n*(n+1)/2
for i in range(1+n):
if c >= i:
c -= i
print(int(c)) |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #!/usr/bin/python
def solve():
w,c = map(int,raw_input().split())
while 1:
for i in xrange(1,w+1):
if c<i:
return c
if c==0:
return 0
c-=i
print solve()
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | [n, m] = map(int, map(int, raw_input().split()))
rem = m % (n * (n + 1) / 2)
for i in range(1, n+1):
if rem >= i:
rem = rem-i
else:
print rem
break |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n=list(map(int,input().split()))
s=0
while(True):
for i in range(1,n[0]+1):
if(i<=n[1]):
n[1]=n[1]-i
else:
print(n[1])
s=s+1
break
if(s==1):
break
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
void _print(long long t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(long double t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(unsigned long long t) { cerr << t; }
... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | a,b=map(int,input().split())
i=1
while b>=i:
b-=i
if i<a:
i+=1
else:
i=1
print(b) |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n, m = map(int, input().split())
c = 0
l = []
for i in range(1, n+1):
l.append(i)
while True:
if m >= l[c%n]:
m -= l[c%n]
else:
break
c += 1
print(m) |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | def preprocessing():
n = 50
chips = [0] * (n + 1)
for i in range(n + 1):
chips[i] = i * (i + 1) // 2
return chips
def main():
full_round_chips = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253,
276, 300, 325, 351, 3... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
if (a == 0) return b;
return gcd(b % a, a);
}
void print_array(int arr[], int n) {
for (int i = 0; i < n; i++) cout << arr[i] << ' ';
cout << endl;
}
void print_vector(const vector<int> &a) {
for (int i = 0; i < (int)a.size(); i++) cout << ... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class C {
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
const int INF = int(1e9);
const int UNF = int(1e5) + 123;
inline void boost() {
ios_base::sync_with_stdio(0);
cin.tie(0);
}
int main() {
boost();
int n, m;
cin >> n >> m;
int t = 1;
while (m >= t) {
m -= t;
if (t == n) {
t = 1;
} else {
... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.io.IOException;
import java.util.Scanner;
public class A92 {
public static void main(String args[]) throws IOException {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), m = sc.nextInt();
op: while (1 > 0) {
for (int i = 1; i < n + 1; i ++) {
if (m - i >= 0) m = m - i; else break o... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | s=raw_input().split()
n=int(s[0])
m=int(s[1])
m%=n*(n+1)/2
i=1
while(m-i>=0):
m-=i
i+=1
print m
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n,m = map(int, input().split())
s = (n*(n+1))//2
if s == m:
print(0)
elif s > m:
ans = n
while s > m:
s -= ans
ans -= 1
print(m-s)
else:
s,i,f = m % s,1,0
while f < s:
f += i
i += 1
... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
while (scanf("%d %d", &n, &m) != EOF) {
int a = (1 + n) * n / 2;
int num = m;
if (a < m) {
num = m - a * (m / a);
}
for (int i = 1; i <= n + 1; i++) {
if (num < i) {
printf("%d\n", num);
break;
... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n,m=map(int,input().split())
i=0
while (i%n)+1<=m and m>0:
m=m-(i%n)-1
i=i+1
print(m) |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.util.*;
import java.math.*;
import java.io.*;
public class main {
public static void main(String[] args) {
new main().solve();
}
public void solve(){
int n=sc.nextInt();int m=sc.nextInt();
for(int i=1;i<=n;i++){
if(m>=i)
m=m-i;
else{
... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.util.Scanner;
public class Chips {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n=scan.nextInt();
int m=scan.nextInt();
m%=n*(n+1)/2;
//System.out.println(m);
for(int i=1;i<=n;i++)
{
if(m<i)
{
break;
}
m-=i;
}
System.out.println(m);... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n,m=map(int,input().split(" "))
m=m%((n*(n+1))//2)
for i in range(1,n+1):
if (m>= i):
m-=i
else: break
print(m) |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int d = (n * (n + 1)) / 2;
m = m % d;
for (int i = 1; i <= n; i++) {
if (m - i == 0) {
cout << "0\n";
return 0;
} else if (m - i < 0) {
cout << m << "\n";
return 0;
} else
m = m - i;
... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n, m = map(int, input().split())
status = True
while status:
for i in range(1, n + 1):
if m >= i:
m -= i
else:
status = False
break
print(m) |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | def coinCount(n, m):
m = m % (n * (n + 1) // 2)
i = 1
while m > 0:
if m < i:
return m
m -= i
i += 1
return 0
n, m = map(int, input().split())
print(coinCount(n, m)) |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. 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: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n, m = map(int, raw_input().split())
a = 1
while m >= a:
m -= a
a = a % n + 1
print m |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n,m = map(int, raw_input().split(" "))
d = (n*(n-1))/2 +n
h = m % d
if h == 0:
print "0"
exit(0)
for i in range(1,h+1):
#print i
h -= i
if h-i <= 0:
print h
break
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | # import sys
# sys.stdin=open("input.in","r")
n,m=map(int,input().split())
m=(m%int(n*(n+1)/2))
for i in range(1,m+1):
if((m-i)>=0):
m-=i
else:
break
print(m) |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n, m = map(int, input().split())
m = m % (n * (n + 1) // 2)
for i in range(1, n + 1):
if m >= i:
m -= i
else:
break
print(m) |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
int t, i;
scanf("%d %d", &n, &m);
i = 1;
while (1) {
if (m - i >= 0) {
m = m - i;
} else {
printf("%d\n", m);
break;
}
i++;
if (i == n + 1) {
i = 1;
}
}
return 0;
}
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, x, y, i;
cin >> n >> m;
i = 1;
while (m) {
if (i > n) i = 1;
if (m < i) break;
m -= i;
i++;
}
cout << m << endl;
return 0;
}
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n,m=map(int,raw_input().split())
i=1
m%=(n+1)*n/2
while m>=i:
m-=i
i+=1
print m
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner r = new Scanner(System.in);
int n = r.nextInt();
int m = r.nextInt();
int i = 0;
while(true){
if(m >= (i+1))
m -= i+1;
else break;
i = (i+1)%n;
}
System.out.println(m);
}
}
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | walrus, chips = map(int, input().split())
while(True):
for i in range(walrus):
if(i + 1 <= chips):
chips -= (i + 1)
else:
print(chips)
exit() |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import sys
import math
n, m = [int(x) for x in (sys.stdin.readline()).split()]
ss = m % int(((1 + n) * n) / 2)
if(ss == 0):
print(0)
exit()
d = int(math.sqrt(1 + (ss * 2) * 4))
sq = 0
if(int((1 + d) / 2) != 1):
sq = int((1 + d) / 2 - 1)
else:
sq = 1
result = int(ss - ((sq + 1) * sq / 2))
prin... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.*;
import java.util.*;
/**
*
* @author N-AssassiN
*/
public class Main {
private static BufferedReader reader;
private static BufferedWriter out;
private static StringTokenizer tokenizer;... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | ri = lambda: raw_input().strip()
n, m = map(int, ri().split())
remain = m % (n * (n+1) / 2)
for i in xrange(1, remain+1):
if i > remain:
break
else:
remain -= i
print remain
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.util.Scanner;
public class CF28
{
public static void main(String[] args)
{
Scanner read = new Scanner(System.in);
int n = read.nextInt(), m = read.nextInt(), counter = 0;
do {
counter++;
if (counter >= n + 1) counter = 1;
... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
int n= sc.nextInt();
int m= sc.nextInt();
for(int i=1;i<=n;i++){
if(m<i)
break;
m-=i;
if(i==n){
i=1;
i--;
}
}
System.out.print(m);... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
int main() {
int n_chip, n, i, j, k, restc, f = 0;
scanf("%d", &n);
scanf("%d", &n_chip);
k = n_chip;
for (i = 0; i <= k; i++) {
for (j = 1; j <= n; j++) {
if (n_chip >= j) {
n_chip = n_chip - j;
} else {
restc = n_chip;
f = 1;
break;
... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n, m = map(int, input().split())
x = int((1 + n) / 2 * n)
if x < m:
m -= x * (m // x)
while m > 0:
for i in range(1, n + 1):
m -= i
if i != n and m - i <= 0:
print(m)
exit(0)
print(0)
elif x == m:
print(0)
else:
while m > 0:
for... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.util.Scanner;
public class Chips
{
public static int solution(int n,int m)
{
int left=m;
boolean check=true;
while(left>0&&check)
{
for(int i=1;i<=n;i++)
if(left>=i)
left-=i;
else
check=false;
}
return left;
}
public static void main(String[] zima)
{
Scanner sc=ne... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.util.*;
import java.io.*;
public class Olimp {
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(System.in);
int n=in.nextInt();
int m=in.nextInt();
for (int i = 1; m>=0; i++) {
if(m-i<0){
System.out.println... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n, m = input().split()
n, m = int(n), int(m)
i = 1
while True:
if m >= i:
# print(m, j)
m -= i
if i >= n:
i = 1
else:
i += 1
else:
break
print(m)
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | # bsdk idhar kya dekhne ko aaya hai, khud kr!!!
# from math import *
# from itertools import *
# import random
n, m = map(int, input().split())
temp = n * (n + 1) // 2
for i in range(100000000):
if temp <= m:
m -= temp
elif temp > m:
break
if m == 0:
print(0)
else:
for i in range(1, n + ... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n, m = map(int, input().split())
m %= int(n*(n+1)/2)
for i in range(1,n+1):
if m < i:
break
m -= i
print(m) |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int n=input.nextInt();
int m=input.nextInt();
boolean f=true;
while(m>0 && f){
for (int i=1 ; i<=n && f; i++) {
if(m>=i)
m=m... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n, m = map(int,
input().split())
c = n*(n+1)//2
m%=c
for i in range(1,
n+1):
if m >= i:
m -= i
else:
break
print(m)
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.io.*;
import java.util.*;
public class A92 {
public static void main(String[] args)throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] NM = br.readLine().split(" ");
int n = Integer.parseInt(NM[0]);
int m = Integer.parseI... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | def nis():
return map(int, raw_input().split())
def seq_sum(n):
return (n * (n + 1)) / 2
n, m = nis()
s = seq_sum(n)
r = m % s
print r - seq_sum(int((((1 + 8 * r)**0.5 - 1) / 2))) |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... |
if __name__ == '__main__':
n, m = [int(x) for x in raw_input().split()]
m %= n * (n+1) // 2
for i in range(n):
if m >= i + 1:
m -= i + 1
else:
print m
break
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long n) {
long long p = 1;
while (n > 0) {
if (n % 2) {
p = p * a;
}
n >>= 1;
a *= a;
}
return p;
}
long long power(long long a, long long n, long long mod) {
long long p = 1;
while (n > 0) {
if (n % 2)... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n,m=map(int,input().split())
l=[]
j=1
for i in range(1,n+1):
l.append(j)
j+=i+1
if m in l:
print(0)
elif m > l[-1]:
k=m%l[-1]
a=0
for i in range(len(l)-1):
if l[i] < k and l[i+1] > k:
a=k-l[i]
break
print(a)
else:
a=0
for i in range(len(l)-1):
if l[i] < m and l[i+1] > m:
a=m-l[i]
break
print(a... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
scanf("%d%d", &n, &m);
int i = 1;
while (m >= i) {
m -= i;
if (i == n)
i = 1;
else
++i;
}
printf("%d\n", m);
}
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
class Point3D {
double x;
double y;
double z;
public Point3D(double x, double y, double z) {
su... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int n, m;
cin >> n >> m;
int total = (n * (n + 1)) / 2;
if (total <= m) m = (m % total);
for (int i = 1; i <= n; i++) {
if (m >= i)
m -= i;
else
break;
}
cout << m << endl... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | data=(input()).split()
n=int(data[0])
m=int(data[1])
c=1
w=[0]*n
for i in range(n):
w[i]=c
c=c+1
v=1
while m>0 and v==1:
for i in range(n):
if m>=w[i] and v==1:
m=m-w[i]
else:
v=0
print (m)
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import math
from collections import defaultdict, Counter, deque
INF = float('inf')
def gcd(a, b):
while b:
a, b = b, a%b
return a
def isPrime(n):
if (n <= 1):
return False
i = 2
while i ** 2 <= n:
if n % i == 0:
return False
i += 1
return True
def primeFactor(n):
if n % 2 == 0:
return 2
i = 3
... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n, m = map(int, raw_input().split())
ok = False
while not ok:
for i in range(1, n + 1):
if m >= i:
m -= i
else:
ok = True
break
print m
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | morj, fishek = map(int,raw_input().split())
total_morj = 0
for i in range(1,morj+1):
total_morj += i
if fishek == total_morj:
print(0)
elif fishek < total_morj:
for i in range(1,morj+1):
if fishek < i:
print (fishek)
break
else:
fishek -= i
else:
ne... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | /**
*
* @author Saransh
*/
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
try
{
Pars... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.util.Scanner;
public class Chips{
public static void main(String arg[]){
int num;
int chips;
Scanner input= new Scanner(System.in);
num=input.nextInt();
chips=input.nextInt();
for (int i=1;i<=num;i++){
if(chips>=i){
chips=chips-i;
}
else{
break;}
if (num==i){
i= 0;
... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, i, p, sum = 0;
scanf("%d %d", &n, &m);
while (sum < m) {
for (i = 1; i <= n; i++) {
sum += i;
if (sum > m) break;
if (sum <= m) p = sum;
}
}
printf("%d", m - p);
return 0;
}
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class A92 {
FastScanner in;
PrintWriter out;
public void solve() throws IOException {
int n... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
;
long long int n, m;
cin >> n >> m;
long long int sum = (n * (n + 1)) / 2;
if (sum < m) m %= sum;
if (sum == m)
cout << 0;
else {
lo... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | n, m = map(int, input().split())
if n == 1:
print(0)
else:
while m >= n * (n + 1) // 2:
m -= n * (n + 1) // 2
cur = 1
while m >= cur:
m -= cur
cur += 1
print(m)
|
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | '''input
50 10000
'''
n,m = map(int,raw_input().split())
ans = 0
i = 0
while m > 0:
if (i + 1) > m:
ans = m
break
m -= (i+1)
i += 1
i %= n
print ans |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | /*
ID: vespin81
LANG: JAVA
TASK: dualpal
*/
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.ut... |
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.
The presenter has m chips. The ... | import sys
from array import array # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
n, m = map(int, input().split())
m %= n * (n + 1) // 2
for i in range(1, n + 2):
if m < i:
print(m)
exit()
m -= i
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.