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 ... | import java.util.Scanner;
public class Main {
public static void main(String [] args) {
Scanner sr = new Scanner(System.in);
int n = sr.nextByte();
int m = sr.nextInt();
for (int i=1;i<=n; i++) {
m=m-i;
if (m<0){
System.out.print(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 ... | #include <bits/stdc++.h>
using namespace std;
long long n, m, sum;
int main() {
cin >> n >> m;
if ((n * (n + 1) / 2) < m) m = m % (n * (n + 1) / 2);
long long i = 1;
while (m > 0) {
m -= i;
if (m < i + 1) break;
i++;
}
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 ... | n,m=map(int,input().split())
i=0
while((m-i)>=0):
for i in range(1,n+1):
if m-i>=0:
m=m-i
else:
break
if(i==n):
i=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 ... | # This is second problem
walruses,chips = input().split()
counter = 0
wal = [0]*int(walruses)
pointer, remain, counter = 0, int(chips), 0
for i in range(1,int(walruses) + 1):
counter = counter + 1
wal[i-1] = counter
if int(chips) > int(walruses):
repeat = int(chips)//sum(wal)
wal = wal*(repeat + 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 ... | n,m=map(int,input().split())
a=1
while True:
if m<a:
break
m-=a
if a==n:
a=1
else:
a+=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())
flag = False
while True:
for i in range(n+1):
if m-i >= 0:
m -= i
else:
flag = True
break
if flag: 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 Chips {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
int m = Integer.par... |
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
[n,m] = [int(x) for x in sys.stdin.readline().split()]
tot = m - m/(n*(n+1)/2)*(n*(n+1)/2)
for x in range(1, n+1):
tot = tot - x
if tot < 0:
print tot + 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 ... | n, m = map(int, input().split())
c = 0
while True:
for i in range(1, n + 1):
if m >= i:
c += 1
m -= i
else:
break
if c != n:
break
c = 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 java.util.*;
public class morsas {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int m = in.nextInt();
for(int i = 1; i<=n; i++){
if(i>m || m==0)break;
else m-=i;
if(i==n)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 ... | import java.util.Scanner;
public class chips {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int x=in.nextInt();
int y=in.nextInt();
int Switch=0;
int carry=y;
boolean f=false;
while(true){
for(int i=1;i<=x;i++){
if(carry-i >=0){
if(Switch==i && x!=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.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Main
{
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int n=s.nextInt(),k=s.nextInt();
k=k%(n*(n+1)/2);
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 ... | import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
long sum = 0;
int count = 1;
do {
if (count > N)
co... |
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 a{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int c = sc.nextInt();
int w = 0;
while(c >= (1 + w % n)){
c -= 1 + w % n;
w++;
}
System.out.println(c);
}
}
//n** {{4 11}}
//n** {{17 107}}
/... |
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 New2016{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int ved = in.nextInt();
while(ved>0){
for(int i = 1; i <= n; i++){
ved -= i;
if(ved<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;
void CP() {
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
return;
}
int main() {
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
int n, m;
cin >> n >> m;
int a[n + 1];
a[1] = 1;
for (int i = 2; i <= n; i++) {
a[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 ... | import java.awt.desktop.PreferencesEvent;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Ladder {
public static void main(String[] args) throws IOException {
//BufferedReader reader=new BufferedReader(new FileReader("input.txt"));
//PrintWriter pw=new PrintWriter(... |
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 ... |
ab= input().split()
a= int(ab[0])
b= int(ab[1])
test=[]
for i in range(1,a+1):
test.append(i)
c= b//a
c=c+1
test= test*c
k=0
while b-test[k]>=0:
b=b-test[k]
k=k+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 ... | warlus,chips=map(int,input().split())
#chips %= (chips*(chips+1)/2)
i=1
while True:
if chips ==0:
break
if i==warlus+1:
i=1
if chips>=i:
#print(chips, i , sep=' ')
chips-=i
else:
break
i+=1
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 ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, i_thWalrus = 1;
cin >> n >> m;
while (m >= i_thWalrus) {
m -= i_thWalrus;
i_thWalrus++;
if (i_thWalrus == n + 1) i_thWalrus = 1;
}
cout << 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())
m %= n * (n + 1) / 2
for i in range(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 ... | /* 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 Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
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;
using ll = long long;
ll res(ll n, ll m) {
ll k = ((n) * (n + 1)) / 2;
while (m > k) {
m -= k;
}
for (ll i = 1; i <= n; i++) {
m -= i;
if (m == 0) return 0;
if (m < 0) {
m += i;
return m;
}
}
return k;
}
int main() {
ll 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 ... | n, m = map(int, input().split())
m %= (n * (n + 1) // 2)
i = 1
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 ... | """n=int(raw_input())
for i in range(n):
t=raw_input()
temp=t[1:]
print sum(t[i]==temp[i] for i in range(0,len(temp)))
"""
"""
n = raw_input()
for i in range(0,n):
t=raw_input()
for j in range(0,len(t)-1):
if t[j]==t[j+1]:
r=r+1
print r
"""
"""
n,t=int(raw_input()),raw_input()
print sum(t[j]==t[j+1] for j 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;
long long MOD = 1000000007;
void FASTIO() {
ios_base::sync_with_stdio(false);
cin.tie(0);
}
long long LongestCommonSubsequnce(string a, string b, long long i,
long long j) {
if (i == a.length() || j == b.length()) {
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 n, m, a[100];
int main() {
cin >> n >> m;
int i = 1;
while (m >= i) {
m -= i;
i++;
if (i > n) 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 ... | #include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
int n, m;
while (cin >> n) {
cin >> m;
int x = 0;
for (int i = 1; i <= n; i++) {
x = x + i;
}
while (m >= x) {
m = m - x;
}
for (int i = 1; i <= m; i++) {
m = m - i;
}
cout << 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 n, m;
int main() {
scanf("%d %d", &n, &m);
m %= n * (n + 1) / 2;
for (int i = (1); i < (n + 1); ++i)
if (m >= i) m -= i;
printf("%d\n", 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 ... | n,m=list(map(int,input().split()))
i=0
while(m>i):
m=m-i-1
i=(i+1)%n
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;
/*
* Name: Saleh Alolayan
* ID: 201411029
*/
public class Chips {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int people = input.nextInt();
int chips = input.nextInt();
if((people == 1 && chips == 1)||(peopl... |
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 NWarm, NChip;
cin >> NWarm >> NChip;
int temp = NWarm * (NWarm + 1) / 2;
int ans = NChip % temp;
int i;
for (i = 1; i <= temp; i++) {
ans = ans - i;
if (ans < 0) break;
}
int ans1 = ans + i;
cout << ans1 << 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 ... | a = list(input().split(' '))
n, m = int(a[0]), int(a[1])
res = 0
i = 1
while m > 0:
m -= i
if (i == n):
i = 1
else:
i += 1
if m - i < 0:
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.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Stack;
public class george
{
static class Reader
{
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPoint... |
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
def readints() :
l = sys.stdin.readline()
return map(int, l.split(' '))
def readstring() :
l = sys.stdin.readline()[:-1]
return l
def readint() :
l = sys.stdin.readline()
return int(l)
def clearchars(s, chars) :
for c in chars :
s = s.replace(c, '')
return s
def g... |
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 Solution {
private static void solve(InputReader in, OutputWriter out) {
int n, m;
n = in.nextInt();
m = in.nextInt();
int s = n * (n + 1) / 2;
m %= s;
for (int i = 1; i <= n; i++)
if (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())
tem = 0
i = 1
while 1:
if i == n + 1: i = 1
tem += i
if tem > m:
tem -= i
break
i -= -1
print(m - tem) |
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 mod = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 123;
const int N = 2e5 + 123;
const int INF = 1e9 + 1;
const long long INFL = 3e18 + 1;
const double pi = acos(-1.0);
const double eps = 1e-9;
int n, m;
inline void boost() {
ios_base ::sync_with_stdio(0);
cin.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 ... | n, m = map(int, input().split())
Chips = 0
i = 1
while Chips + i <= m:
Chips += i
i += 1
if i > n:
i = 1
print(m - Chips)
# HaPpY NoWrUz 1398
# UBCF
# CodeForcesian
# ♥
# خدایااااا شکرت |
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
s=0
while(s<=m):
c=c+1
s=s+c
if(c==n and s<=m):
c=0
s=s-c
print(m-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 ... |
a, b=map(int, input().split())
cnt=0
while(b>cnt):
b=b-cnt-1
cnt=(cnt+1)%a
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 ... | from __future__ import division
data = raw_input().split()
data = [int(i) for i in data]
# 32 6864
# z = 6864
z = data[1]
# i = 32
i = data[0]
def a():
n = 0
r = 0
for j in range(1, i + 1):
n += j
if z % n == 0:
print 0
return
if n < z:
t = z - ((z // n) * 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>
using namespace std;
int main() {
std::ios::sync_with_stdio(false);
long long int n, m;
cin >> n >> m;
long long int cur = 1;
while (m) {
if (m < cur) {
return cout << m << endl, 0;
} else
m -= cur;
if (cur == n)
cur = 1;
else
cur++;
}
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 ... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int m, n, i;
while (cin >> n >> m) {
i = 1;
do {
m = m - i;
i++;
if (i > n) i = 1;
} while (m >= 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 ... | def fishki(n, m):
count = 1
while m > 0:
if m - count < 0:
break
m -= count
count += 1
if count > n:
count = 1
return m
N, M = [int(i) for i in input().split()]
print(fishki(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 ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; m >= (i % (n + 1)); i++) {
m -= (i % (n + 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 ... | n, m =map(int,input().strip().split())
w=[a for a in range(1,n+1)]
counter=0
while True:
# print(counter)
if m<w[counter]:
print(m)
break
m-=w[counter]
counter = (counter+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())
flag = 0
while 1:
for i in range(1,n+1):
if m<i:
flag = 1
break
else:
m -= i
if flag==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 ... | walrus, chip = map(int, input().strip().split())
i = 1
while True:
for i in range(1, walrus + 1):
chip -= i
#print(f'The {i}th walrus got {i}. Now there are {chip} chips.')
if chip < 0:
print(chip + i)
exit()
elif chip == 0:
print(chip)
... |
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 array(n,m):
m%=(n * (n+1) // 2)
for i in range(1,n+1):
if (m < i):
break
m-=i
print(m)
n,m=map(int,input().split())
array(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 ... | if __name__ == '__main__':
n,m = map(int, input().split())
i = 1
while i <= n:
if m == 0:
print(str(0))
break
if m < i:
print(str(m))
break
if i == n:
m -= i
i = 1
else:
m -= i
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, raw_input().split())
m %= n*(n+1)/2
for i in range(1, n+1):
if m<i:
print m
exit()
else:
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 ... | morj, fish = map(int, input().split())
flag = True
while flag:
for i in range(1, morj+1):
if fish < i:
print(fish)
flag = False
break
fish -= 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;
int check(int n, int m) {
int arr[55], i, j;
for (i = 1; i <= 50; i++) {
arr[i] = (i * (i + 1)) / 2;
}
if (arr[n] < m) {
check(n, m - arr[n]);
} else if (arr[n] == m)
return 0;
else
for (j = 1; j <= n; j++) {
if (arr[j] > m) {
retur... |
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())
num = m%((n*(n+1))//2)
for i in range(1,n+1):
num -= i
if num==0:
print(0)
break
elif num<0:
num += i
print(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 ... | #include <bits/stdc++.h>
int main() {
int n, m, i, sum = 0;
while (scanf("%d%d", &n, &m) != EOF) {
sum = 0;
while (1) {
for (i = 1; i <= n; i++) {
if (sum + i <= m)
sum += i;
else
break;
}
if (i <= n) break;
}
printf("%d\n", m - sum);
}
retur... |
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().strip().split()))
t=0
for j in range(m):
if t>0:
break
else:
for k in range(1,n+1):
m=m-k
if m==0:
t +=1
print("0")
break
elif m<0:
t +=1
print(m+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 ... | n,m=map(int,input().split())
s=sum(range(1,n+1))
m%=s
for j in range(1,n+1):
if (j>m):
break
else:
m-=j
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.Arrays;
import java.util.Scanner;
import static java.lang.Math.*;
public class p1b
{
public static void debug(Object... obs)
{
System.out.println(Arrays.deepToString(obs));
}
public static void main(String[] args) throws Exception
{
Scanner sc = new Scanner(System.in);
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>
using namespace std;
int main() {
long n, m, i = 1;
cin >> n >> m;
long need = 0;
while (need < m) {
if (i > n) i = 1;
need += i;
i++;
}
i--;
if (need > m) {
need -= i;
}
cout << m - need;
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;
for (int i = 1; i != 0; i++) {
if (i > n) {
i = 1;
}
if (m >= i) {
m = m - i;
} else
break;
}
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 ... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n, k;
cin >> n >> k;
long long sum = n * (n + 1) / 2;
while (k > sum) {
k -= sum;
}
long long x = (-1 + sqrt(1 + (8 * k))) / 2;
long long y = (x * (x + 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 ... | q=lambda:map(int,input().split())
qi=lambda:int(input())
qs=lambda:input().split()
n,m=q()
c=m%sum(i for i in range(1,n+1))
for i in range(1,n):
if c-i>=0:
c-=i
else:break
print(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 ... | import java.util.*;
import java.io.*;
public class Chips{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String[] next = sc.nextLine().split("\\s");
int n = Integer.parseInt(next[0]);
int m = Integer.parseInt(next[1]);
int i = 0;
while(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.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Chips {
public static void main(String args [] ) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.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,m = map(int, input().split())
def summation(a):
return (a*(a+1)//2)
x=[]
for i in range(n):
x.append(summation(i+1))
m = m % x[-1]
if m==0:
print(0)
else:
for i in range(n):
if x[i] > m:
m -= x[i-1]
break
elif x[i] == m:
m = 0
bre... |
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, j, sum = 0, rem, x;
cin >> n >> m;
i = 0;
while (x = (i % n) + 1) {
m -= x;
if (m < 0) {
m += x;
cout << m << "\n";
return 0;
}
i++;
}
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.util.Scanner;
public class Chips {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int chips = sc.nextInt();
for (int i = 1; i <=n; i++) {
if (chips==0) {
break;
}
chi... |
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(map(int, input().split()))
while ( (n*(n + 1)) // 2 ) <= m:
m -= ( (n*(n + 1)) // 2 )
i = 1
while m - i >= 0:
m -= i
i = i + 1
if i > n:
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 = (int(x) for x in input().split())
cur = 1
while m >= cur:
m -= cur
cur += 1
if cur == n + 1:
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 ... | #include <bits/stdc++.h>
using namespace std;
void solve(int n, int m) {
m %= (n * (n + 1)) / 2;
int temp = 0;
for (int i = 1; i <= n; i++) {
if (temp + i <= m)
temp += i;
else
break;
}
cout << m - temp << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int 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 ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int k = n * (n + 1) / 2;
int p;
p = m % k;
int i, j;
for (i = 1; i <= n; i++) {
p = p - i;
if (p < 0) {
cout << p + i;
break;
}
if (p == 0) {
cout << "0";
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,raw_input().split(" "))
array=[e+1 for e in range(n)]
i=0
while (array[i % n]<=m):
m= m-array[i % n]
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 ... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m, k, a, sum = 0;
cin >> n >> m;
for (long long i = 1; i <= n; i++) {
sum += i;
}
a = k = m % sum;
if (a == 0) {
cout << a;
return 0;
}
for (long long i = 1; i <= k; i++) {
a -= i;
if (a == 0) {
cout << 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 ... |
import java.io.BufferedInputStream;
import java.util.Arrays;
public class C092A {
public void solve() throws Exception {
int n = nextInt();
int m = nextInt();
int i = 1;
while (true) {
if (i > n) {
i = 1;
}
if (m >= i && m > 0) {
m -= i;
} else {
println(m);
return;
}
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, raw_input().split())
def f(x): return x*(x+1)/2
m -= m/f(n)*f(n)
print m-max([f(i+1)*(f(i+1)<=m) for i in range(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 ... | # import sys
# sys.stdin = open("test.in","r")
# sys.stdout = open("test.out","w")
n,k=map(int,input().split())
i=1
while k>=i:
k-=i
if i<n:
i+=1
else:
i=1
print(k)
|
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long n, m, power[400010], H1[400010], H2[2010];
char c, table[210][2010];
long long get_hash(int len, int rin) {
int l = len * m + 1, r = (rin + 1) * m;
return (H1[r] - H1[l - 1] * power[r - l + 1] % mod + mod) % mod;
}
int main() {
scanf... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int n, m;
char s[2005][205], t[205][2005];
long long tmp, now, f[205 * 205], g[2005], h[2005], p[205][2005];
map<long long, int> mp;
int main() {
scanf("%d%d", &n, &m);
f[0] = 1;
for (int i = 1; i <= m * m; i++) f[i] = f[i - 1] * 26 % 1000000007;
for (int i = 0; i <... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T>
inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
const int N = 2005;
const int M = 205;
char board1[N][M];
char board2[M][N];
co... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
long long mod;
const long long N = 2e3 + 5;
void vjudge() {
if (fopen("input.txt", "r")) {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
}
... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2005, maxm = 205;
const int seed1 = 23333, seed2 = 18869;
const int MOD[2] = {998244353, 1000000009};
int a[maxn][maxm][2], b[maxm][maxn][2];
char s[maxn][maxm], t[maxm][maxn];
int pow1[maxn][2], pow2[maxn][2];
int n, m;
bool check(int r, int c) {
for (in... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int n, m;
char a[2222][222], b[222][2222];
unsigned long long p[2], pw[2][200 * 200 + 1];
unsigned long long ph[2][222][2222], h[2][2222], ch[2], temp[2][2222];
void read() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) cin >> a[i... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
char a[2000][201];
char b[200][2001];
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < m; i++) cin >> b[i];
int i, j, k;
for (i = 0; i <= n - m; ++i) {
for (j = 0; j <= n - m; ++j) {
bool c = 1;
... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
const long long N = 2020;
const long long Q = 3000100;
const long long mod = 1e9 + 7;
const long long block = sqrt(N);
using namespace std;
int n;
int m;
char a[N][N / 10];
char b[N / 10][N];
map<vector<long long>, vector<int> > used;
vector<long long> make(vector<pair<int, int> > v) {
vector... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int MAXLEN = 1e6;
struct RH_single {
static const unsigned long long int B = 127;
static const unsigned long long int P = 1e9 + 7;
static unsigned long long int pow[MAXLEN];
static unsigned long long int add(unsigned long long int x,
... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int max1 = 2000 + 7, max2 = 200 + 7;
int n, m;
char s1[max1][max2], s2[max2][max1];
int t1[max1], t2[max2][max1];
map<string, int> mp;
int f[max2];
bool solve(int id) {
f[0] = f[1] = f[2] = 1;
for (int i = 2; i <= m; ++i) {
int j = f[i];
while (j > 1 && t2... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 2;
const long long pr = 997;
const int mod = 1e9 + 7;
int n, m;
long long hs[202][N], ar[N], pw[N];
string a[N], b[N], s;
long long get(int l, int r, int k) {
long long h = (hs[k][r] - hs[k][l - 1] + mod) % mod;
h = (h * pw[N - l]) % mod;
return h;... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int n, m, ar[2001][201], ars[201][2001], pr = 31;
map<int, int> mp;
int main() {
cin >> n >> m;
for (int i = 0; i < n; i++) {
scanf("\n");
for (int j = 0; j < m; j++) {
char ch;
scanf("%c", &ch);
ar[i][j] = ch - 97;
}
}
for (int i = 0; ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using std::map;
const int base = 31, mod = 1e9 + 7;
const int N = 2005;
int n, m;
char s[N];
unsigned long long H[N];
unsigned long long h1[N][N], h2[N][N];
unsigned long long powb[N], powm[N];
map<unsigned long long, int> M;
signed main() {
int n, m;
register int i, j;
scanf("%d%d", &n, ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int in(vector<int> a, vector<int> b) {
int n = a.size(), m = b.size();
vector<int> v;
for (int i = 0; i < n; ++i) {
v.push_back(a[i]);
}
v.push_back(-2);
for (int i = 0; i < m; ++i) {
v.push_back(b[i]);
}
int s = n + m + 1;
vector<int> pref(s);
f... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int MAX_ROW = 2000 + 7;
const int MAX_COLUMN = 200 + 7;
const int BASE = 2807;
const int MOD = 1e7 + 7;
int n, m;
char TableA[MAX_ROW][MAX_COLUMN], TableB[MAX_COLUMN][MAX_ROW];
int HashA[MAX_ROW][MAX_COLUMN], HashB[MAX_COLUMN][MAX_ROW], Pow2807[MAX_ROW],
HashFindi... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
bool check_overlap(char map1[2000][200], char map2[200][2000], int off1,
int off2, int M, int *last_fail) {
int pos1[2] = {off1 + last_fail[0], last_fail[1]};
int pos2[2] = {last_fail[0], off2 + last_fail[1]};
if (map1[pos1[0]][pos1[1]] != map2[pos2[0]][pos2[1]]) {
... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1061109567;
const ll INF = 4557430888798830399;
const int MOD = 1e9 + 7;
const int p = 131;
const int q = 113;
int n, m;
char a[2005][205];
char b[205][2005];
int hashp[205];
int hashq[2005];
int s[2005][2005];
int t[2005][2005];
int ge... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
template <class U, class T>
void Max(U &first, T second) {
if (first < second) first = second;
}
template <class U, class T>
void Min(U &first, T second) {
if (first > second) first = second;
}
template <class T>
void add(int &a, T b) {
a = (a + b) % 1000000007;
}
int... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int mod = 997;
const int maxn = 2e3 + 7;
const int maxm = 2e5 + 7;
int ar[maxn], m, n;
bool bo[maxn];
char ch1[maxn][maxn], ch2[maxn][maxn];
int ar1[maxn], ar2[maxn][maxn];
void init() {
for (int i = 0; i < n; i++) {
ar1[i] = 0;
for (int j = 0; j < m; j++) {... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const unsigned long long MUL = 31;
struct hash_pair {
unsigned long long h1;
long long h2;
hash_pair() : h1(0), h2(0) {}
hash_pair(const hash_pair& src) : h1(src.h1), h2(src.h2) {}
hash_pair(unsigned long long h1, long long h2) : h1(... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class A2 implements Runnable{
public static void main (String[] args) {new Thread(null, new A2(), "_cf", 1 << 28).start();}
public void run() {
DeoxysS fs = new DeoxysS();
PrintWriter out = new PrintWriter(System.out);
System.err.printl... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
string s[3000];
string t[3000];
map<string, int> my;
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) {
char ch[m + 10];
scanf("%s", ch);
s[i] = (string)ch;
}
for (int i = 0; i <= n - m; i++) {
string temp;
for (int j = 0; j < ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class Main implements Runnable {
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numCha... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.