prompt string | response string |
|---|---|
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #coding: utf-8
def primes(DIM):
vals=[True] * DIM
vals[0]=False
vals[1]=False
for i in range(2,DIM):
if vals[i]:
j = i * i
while True :
if j >= DIM :
break
vals[j] = False
j += i
return vals
primes = primes(10 ** 5 + 100)
lista = [0,1,0]
for i in... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
long long N, M, vis[maxn], primes[maxn], tot = 0, arr[505][505];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N >> M;
for (register long long i = 1; i <= N; ++i) {
for (register long long j = 1; j <= M; ++j) {
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | LIMIT = 100000+4
l, c = map(int, raw_input().split())
m = [ list(map(int, raw_input().split())) for x in xrange(l)]
def is_prime(num):
if num == 2 or num == 3: return True
if num < 2 or num%2 == 0 or num%3 == 0: return False
r = int(num**0.5)
f = 5
while f <= r:
if (num % f == 0) or (num % (f+2) == 0): r... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import math
closeprime = [-1]* 100001
primos = []
n= 100001
m = int(math.sqrt(n))
numbers = [1] * ((n)+1)
# generate primes
for i in range(2,m):
num = numbers[i]
if num:
for j in range(i,n,i):
if numbers[j]:
numbers[j] = 0
primos.append(i)
numbers[i]= 1
j=1; ... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.util.*;
public class cf271B{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int n= sc.nextInt();
int m= sc.nextInt();
int[][] matrix = new int[n][m];
int count =0;
int[] primes = new int[100010];
int[] new_primes = new int[100010];
int k... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.invoke.MethodHandles;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
impo... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
int main() {
int i, j, n, m, sum, min, index, R, P, flag, l, k;
int A[500][500], B[500][500];
scanf("%i%i", &n, &m);
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
scanf("%i", &A[i][j]);
}
}
min = 10000000;
for (i = 0; i < n; i++) {
sum = 0;
for (j = 0; ... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... |
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def MAP2():return map(float,input().split())
def LIST(): return list(map(int, input().split()))
def STRING(): return input()
import string
import sys
from heapq import heappop , heappush
from bisect import *
from... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
bool t[100004] = {1, 1};
long long a[502], b[502], i, j, n, m, x;
int main() {
for (i = 2; i * i < 100004; i++)
if (!t[i])
for (j = i * i; j < 100004; j += i) t[j] = 1;
cin >> n >> m;
for (i = 0; i < n; i++)
for (j = 0; j < m; j++) {
long long k = ... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import sys
import math
LIMIT = 100025
is_prime = [True for i in range(LIMIT + 1)]
distance_to_next_prime = [0 for i in range(200000)]
def sieve_of_eratosthenes():
is_prime[0] = is_prime[1] = False
for i in range(2, int(math.sqrt(LIMIT))):
if is_prime[i]:
j = 2
while i * j <= LI... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
bool cmp(char a, char b) { return a > b; }
bool primes[1000001];
vector<long long int> *sieve() {
primes[0] = false;
primes[1] = false;
for (long long int i = 2; i * i < 1000001; i++) {
if (primes[i]) {
for (long long int j = i * i; j < 1000001; j += i) {
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 1000 + 10;
const int inf = 1000 * 1000 * 1000;
vector<int> prime;
bool check[maxn];
int mat[500][500], min_dist = inf, n, m, dist[500 * 500 + 10];
int dist_ele(int r, int c) {
int ele = mat[r][c];
if (dist[ele] != 0) return dist[ele];
int alt =... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | /*
* @Author: steve
* @Date: 2015-06-01 21:08:52
* @Last Modified by: steve
* @Last Modified time: 2015-06-01 21:25:52
*/
import java.io.*;
import java.util.*;
public class PrimeMatrix {
public static void main(String[] args) throws Exception{
BufferedReader entrada = new BufferedReader(new InputStreamRe... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.util.*;
import java.math.*;
import java.io.*;
public class Main {
public static StringTokenizer st;
public static BufferedReader scan;
public static PrintWriter out;
public static void main(String[] args) throws IOException{
scan = new BufferedReader(new InputStreamReader(System.in)... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
vector<long long int> v(1000000 + 1, 0);
void sieve() {
long long int a;
bool prime[1000000 + 1];
memset(prime, true, sizeof(prime));
prime[0] = prime[1] = false;
for (long long int i = 2; i * i <= 1000000; i++) {
if (prime[i]) {
for (long long int j = (... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import math
def isPrime(n):
# Corner cases
if(n <= 1):
return False
if(n <= 3):
return True
if(n % 2 == 0 or n % 3 == 0):
return False
for i in range(5,int(math.sqrt(n) + 1), 6):
if(n % i == 0 or n % (i + 2) == 0):
return F... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | limite = int(10e5)
primos = [True for i in range(limite)]
primos[0] = False
primos[1] = False
for i in range(2,limite):
if primos[i]:
for j in range(i**2, limite, i):
primos[j] = False
distancias = [0 for i in range(limite)]
distancias[0] = 2
distancias[1] = 1
base = int(limite//10 - 1)
while n... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | primo = 200001*[True]
distprimo = 200001*[0];
grid = []
primo[1] = False
for i in xrange(2, 200001):
j = i*i
while j < 200001:
primo[j] = False
j += i
dist = 1000000
for i in xrange(200000, 0, -1):
if primo[i]: dist = 0
distprimo[i] = dist
dist += 1
n, m = map(int, raw_input().s... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | row, column = map(int, input().split())
matrix =[[*map(int,input().split())] for _ in " "*row]
variation = int(1e5+2)
aux = [1,1] + ([0]*variation)
for x in range(2,variation):
aux[x*x::x]= [1] * ((variation-x*x)//x+1)
for y in range(variation,-1,-1):
aux[y]*= aux[y+1] + 1
for i in range(row):
fo... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.util.Scanner;
public class primematrix {
public static boolean a[] = new boolean[100005];
public static void c() {
a[0] = true;
a[1] = true;
for (int i = 2; i < 100005; i++) {
if (a[i] == false) {
for (int j = i * i; j < 100005 && j >= 0; j += i) {
a[j] = true;
}
}
}
}
publ... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
const int N = 500 + 5, M = 1e5 + 5;
long long sum1[N], sum2[N];
int n, m, a[N][N], par[M];
int main() {
cin >> n >> m;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) cin >> a[i][j];
for (int i = par[1] = 1; i * i < M; i++)
if (!par[i])
for (int ... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
bool notPrime[1000005];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n = 1000004, m;
notPrime[0] = notPrime[1] = 1;
vector<int> s;
for (size_t i = 2; i * i <= n; i++) {
if (!notPrime[i]) {
for (size_t j = i * 2; j < n; j +=... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | nearest_prime=[0]*(int(1e5+1))
nearest_prime[0]=2
nearest_prime[1]=1
prime_bool=[0]*(int(1e5+1))
def is_prime(n):
for i in range(2,int(n**0.5)+1):
if n%i==0:
return False
return True
a=[]
for i in range(2,int(1e5)+1):
if is_prime(i):
a.append(i)
prime_bool[i]=1
for i in range(100001,1000001):
if is_pri... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.io.*;
import java.util.*;
import java.math.*;
public class B271 {
public static BufferedReader read = null;
public static PrintWriter out = null;
public static StringTokenizer token = null;
public static void solve()
{
int up = 100003;
boolean[] p = new boolean[up+1];
for(int i=2; i<=up; i+... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | n, m = map(int, input().split())
primes = [1 for _ in range(10**6+1)]
primes[0] = False
primes[1] = False
for i in range(2, 10**6):
if primes[i]:
for j in range(i*i, 10**6, i):
primes[j] = False
grid = []
for i in range(n):
grid.append([])
line = list(map(int, input().split()))
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
const long long prb = 100;
const long long N = 100005;
const long long NN = 105;
const long long HASH1 = 2250119;
const long long HASH2 = 2452343;
const double pi = 3.14159;
const long long MAX = 2e5 + 123;
const long long MOD = 1e9 + 7;
const long long INF = 10000000000000... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | k=[0]*(1000001)
primes=[]
for i in range(2,1000001):
if k[i]==0:
primes.append(i)
for j in range(i,1000001,i):k[j]=1
def bin(x):
lo,hi=0,len(primes)
ans=0
while lo<=hi:
mid = (hi+lo)//2;
if primes[mid]==x:return 0
if primes[mid]<x:lo=mid+1
else:ans=mid;hi=mid... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
int mini = 100000, temp_min;
vector<int> v;
v.push_back(2);
int x = 2;
bool tinka = true;
while (1) {
tinka = true;
for (int i = 2; i < sqrt(x) + 1; i++) {
if (x % i == 0) {
tinka = false;
bre... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | sieve=[0]*2+[1]*100003
for i in range(2,1001):
if sieve[i]:
for j in range(i*2,100003,i):
sieve[j]=0
def next_prime(n):
i = 0
while not sieve[n+i]:
i += 1
return i
for x in xrange(0,len(sieve)):
sieve[x] = next_prime(x)
n,m = map(int,raw_input().split())
matrix = [[... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author alex
*/
pub... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
vector<long long> v;
int prime[100015];
void sieve() {
for (long long p = 2; p * p <= 100009; p++) {
if (prime[p] == 0) {
for (long long i = p * p; i <= 100009; i = i + p) {
prime[i] = 1;
}
}
}
}
void num() {
for (int i = 2; i <= 100009; i+... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | num_rows, num_columns = map(int, input().split())
limit=int(1e5+2)
diffs=[2,1,0,0]+[1,0]*((limit-2)//2)
for i in range(3,limit):
if not diffs[i]:
diffs[i*i::i]=[1]*((limit-i*i)//i+1)
for i in range(limit,4,-1):
diffs[i]*=diffs[i+1]+1
matrix_diffs = [[diffs[j] for j in map(int,input().split())] for i i... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.util.*;
public class CodeForces
{
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
int n = input.nextInt();
int m = input.nextInt();
int[][] array = new int[n][m];
int[] next = new int[100100];
boolean[] primes = sieveOfEratosthenes(1000100);
int min = Intege... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import bisect
def sieve(n):
p = 2
prime = [True for i in range(n+1)]
while p*p<=n:
if prime[p] ==True:
for i in range(p*p,n+1,p):
prime[i] = False
p+=1
c = []
for p in range(2,n):
if prime[p]:
c.append(p)
return c
def transpose(a,n... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.io.*;
import java.util.*;
import java.nio.charset.StandardCharsets;
// import java.math.BigInteger;
public class B {
static Writer wr;
public static void main(String[] args) throws Exception {
// long startTime = System.nanoTime();
// String testString = "";
// InputStream... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.util.Arrays;
import java.util.Scanner;
public class C {
public static int findMaxBinary(int[] lista, int element) {
int izquierda = 0;
int derecha = lista.length-1;
int centro = 0;
boolean isFound = false;
while(!isFound && (izquierda<=derecha)) {
centro = (izquierda + derecha) / 2;
i... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.util.*;
public class inter8 {
static int[] p = new int[120001];
/**
* @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();
int[... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.io.*;
import java.util.*;
public class PrimeMatrix
{
public static void main(String[] args) throws IOException
{
boolean[] primes = new boolean[100010];
ArrayList<Integer> list = new ArrayList<Integer>();
Arrays.fill(primes, true);
primes[0]=false;primes[1]=false;
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
int p[100015], prime[100015], no, ans[500][500], a[500][500];
void pre() {
int i, j;
for (i = 2; i <= 100010; i++) {
if (p[i] != 1) {
for (j = 2; i * j <= 100010; j++) {
p[i * j] = 1;
}
}
}
prime[0] = 2;
no = 1;
for (i = 3; i <= 10001... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | max = 150035
primes = [0 for x in range(max)]
def generatePrimes():
primes[1] = primes[0] = 1
for i in range(2, max):
if primes[i] == 0:
for j in range(i + i, max, i):
primes[j] = 1
for i in range(max-2, -1, -1):
if (primes[i] != 0):
primes[i] += pri... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
int prime_x(int x) {
for (int i = 2; i * i < x + 2; i++) {
if (x % i == 0) {
return 0;
}
}
return 1;
}
int pr[100009];
int z[100007];
int s[509][509];
int main() {
pr[2] = 1;
for (int i = 3; i < 100007; i++) {
pr[i] = prime_x(i);
}
z[100003] ... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.util.Scanner;
public class PrimeMatrix {
public static boolean[] primes = new boolean[1000000];
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
getPrimes();
while (in.hasNextInt()) {
int n = in.nextInt();
int m = in.nextInt();
int[][] arr = new int[n][m];
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import sys
import math
m, n = map(int, raw_input().split())
matrix_list = []
for i in range(m):
matrix_list.append(map(int, raw_input().split()))
list_primes = [0]
def is_prime(n):
if n == 2 or n == 3:
return True
elif n < 2 or n % 2 == 0:
return False
elif n < 9:
return True
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | def _min(x, y):
if x < y:
return x
if y <= x:
return y
n = 100100
prime = [True for i in range(n+1)]
prime[0], prime[1] = False, False
p = 2
while (p * p <= n):
if (prime[p] == True):
for i in range(p * p, n+1, p):
prime[i] = False
p += 1
n = 100100
nextPrime = [0 for _ in range(n+1)]
curren... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
#pragma GCC optimize "trapv"
using namespace std;
std::vector<long long int> v;
const long long int x = 1000007;
void fun() {
bool prime[x + 1];
memset(prime, true, sizeof(prime));
for (long long int p = 2; p * p <= x; p++) {
if (prime[p] == true) {
for (long long int i = p * p;... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.io.*;
import java.util.*;
public class A274 {
/**
* @param args
*/
public static void main(String[] args) {
Scanner in= new Scanner(System.in);
int n=in.nextInt();
int m=in.nextInt();
int [][] g=new int [500+1][500+1];
int [] r=new int [300_00... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
bool isPrime[1000011];
void sieve() {
int N = 1000011;
for (int i = 0; i <= N; i++) isPrime[i] = true;
isPrime[0] = 0;
isPrime[1] = 0;
for (int i = 2; i * i <= N; i++) {
if (isPrime[i] == true) {
for (int j = i * i; j <= N; j += i) isPrime[j] = false;
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #!/usr/bin/env python
from sys import stdin as cin
def main():
n, m = map(int, next(cin).split())
mind = 100000000
sumline = [0] * m
for i in range(n):
line = [pdist[int(k)] for k in next(cin).split()]
mind = min(mind, sum(line))
sumline = [sumline[j] + line[j] for j in range(m... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | def iarr(): return map(int,raw_input().split())
limit = 100010
p = [1] * limit
p[1] = 0
p[0] = 0
for i in xrange(2,limit):
if(p[i]):
for j in xrange(2*i,limit,i):
p[j] = 0
for i in xrange(limit-2,-1,-1):
if(p[i] == 1):
p[i] = 0
else:
p[i] = 1+p[i+1]
[n,m] = iarr()
rmin = ... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import sys, math
def rs():
return sys.stdin.readline().strip()
def ri():
return int(sys.stdin.readline().strip())
def ras():
return list(sys.stdin.readline().strip())
def rai():
return map(int,sys.stdin.readline().strip().split())
def main():
M = 100099
n,m = rai()
arr = []
for i in xran... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.util.*;
import java.io.*;
import java.math.*;
import java.lang.reflect.*;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
OutputWriter out = new OutputWriter(out... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import javax.naming.PartialResultException;
import java.util.*;
import java.io.*;
public class PrimeMatrix {
InputStream is;
PrintWriter out;
String INPUT = "";
ArrayList<Integer> primes;
void solve() throws IOException {
int n= ni(), m= ni();
int[][] arr= new int[n][m];
f... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
bool prime[MAX];
void sieve(int n) {
memset(prime, true, sizeof(prime));
for (int i = 2; i * i <= n; i++)
if (prime[i] == true)
for (int j = i * 2; j <= n; j += i) prime[j] = false;
}
int main() {
sieve(MAX - 1);
int n, m, ans = MA... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... |
from sys import stdin,stdout
input=stdin.readline
import math,bisect
#from itertools import permutations
#from collections import Counter
prime=[1]*102001
prime[1]=0
prime[0]=0
for i in range(2,102001):
j=i
while(j+i<102001):
j+=i
prime[j]=0
#print(prime)
l=[]
n,m=map(int,input().split())
for i in range(n):
t... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
int n, x, a[511][511], m, pr[111111], sz, row[555], col[555], ans, cur,
p[222222];
void calc() {
for (int i = 2; i <= 200000; i++) {
bool t = true;
for (int j = 2; j <= int(sqrt(i)); j++) {
if (i % j == 0) {
t = false;
break;
}
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | limite = int(10e5)
primos = [True for i in range(limite)]
primos[0] = False
primos[1] = False
for i in range(2,limite):
if primos[i]:
for j in range(i**2, limite, i):
primos[j] = False
distancias = [0 for i in range(limite)]
distancias[0] = 2
distancias[1] = 1
base = int(limite//10 - 1)
while n... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import copy, bisect
from math import sqrt
primes = []
top = 10**5+10
pos = [True] * top
for i in range(2, top):
if pos[i]:
for j in range(2*i, top, i):
pos[j] = False
primes = [i for i in range(2, top) if pos[i]]
arr = [];arr2 = []; k = 0; lst = []
n, m = map (int, input ().split ())
ans = 100000000
for i in ran... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #! /usr/bin/env python
#coding=utf-8
MAX_SIZE = 100019
flg = [0 * i for i in range(MAX_SIZE)]
sqrt_i = int(MAX_SIZE ** 0.5)
for i in range(2, sqrt_i):
for j in range(i, MAX_SIZE):
if(i * j >= MAX_SIZE):break
flg[i * j] = 1
primes = [x for x in range(2, MAX_SIZE) if flg[x] == 0]
def minDif(n):
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void ZZ(const char* name, Arg1&& arg1) {
std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
std::cerr.w... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.awt.Point;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import javax.security.auth.kerberos.KerberosKey;
import static java.lang.Math.*;
public class Main {
final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
BufferedReader in;... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import itertools as it
simple_nums = []
def sieve():
""" Generate an infinite sequence of prime numbers.
"""
yield 2
D = {}
for q in it.count(3, 2): # start at 3 and step by odds
p = D.pop(q, 0)
if p:
x = q + p
while x in D: x += p
D[x] = p # new composite found. Mark that
else:
yield q ... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import math
prime=[2,3,5,7,11];d={}
def GeneratePrimes():
for i in range(12,100100):
for j in prime:
if i%j==0:
break
if j*j>i:
prime.append(i)
break
else:
prime.append(i)
for i in range(1,len(prime)+1):
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | from bisect import *
def primes(n):
low = 3
lNum = range(low, n + 1, 2)
iRoot= n ** 0.5
iMid = len(lNum)
i = 0
m = 3
while m < iRoot:
if lNum[i] != 0:
j = (m*m - low) / 2
while (j<iMid):
if (j >= 0):
lNum[j] = 0
j += m
i += 1
m += 2
return [2] + [x for ... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #python3
import sys, threading, os.path
import collections, heapq, math,bisect
import string
from platform import python_version
import itertools
sys.setrecursionlimit(10**6)
threading.stack_size(2**27)
def generate_primes(n):
res = []
isPrime = [True]*(n*5)
isPrime[0],isPrime[1] = 0,0
'''
for... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Watermelon {
static long mod = 1000000007;
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
boolean[] prime=sieveOfErato... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
long long fix(long long cur, long long m) { return ((cur % m) + m) % m; }
long long fast_power(long long x, long long y) {
if (y == 0) return 1;
long long temp = fast_power(x, y / 2);
temp = (temp * temp);
if (y % 2 != 0) temp = temp * x;
return temp;
}
bool prime... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | # specify list capacity
MaxN = 100010
prime_list = [0 for x in range(MaxN)]
prime_list[0] = prime_list[1] = 1
# mark all composite number with 1
for i in range(2, MaxN):
if prime_list[i] == 1:
continue
j = i*2
while j < MaxN:
prime_list[j] = 1
j += i
# then replace all '0' and '1' with prime number
i = Max... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | def Bin(li, x):
i = 0
j = len(li)-1
while i < j:
m = int((i+j)/2)
if x > li[m]:
i = m+1
else:
j = m
return j
def intpolsearch(values, x):
idx0 = 0
idxn = (len(values) - 1)
while (idx0 <= idxn and x >= values[idx0] and x <= values[idxn]):
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #atal 2020.1, feito baseado nas noocoes vistas, conceito do crivuuuuus facilment eencontrado.
# utilizando py py para ver se funciona.
import sys
import math
limit = 100025
minhaListadePrimos = [True for i in range(limit + 1)]
primosSeguintestsss = [0 for i in range(200000)]
def crivandu():
minhaListadePrimos[0... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import bisect
prime=[0]*1000001
i=2
while i*i<1000001:
if prime[i]==0:
for j in range(i*i,1000001,i):
prime[j]=-1
i+=1
lol=[]
for k in range(2,1000001):
if prime[k]==0:
lol.append(k)
x,y=map(int,input().split())
yo=[]
lu=[]
for i in range(x):
yo.append([0]*y)
lu.append(li... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
class Soln {
private:
int n;
public:
Soln() {}
~Soln() {}
};
class Seive {
public:
bool *A;
vector<int> v;
Seive(int n) {
A = new bool[n + 1];
for (int i = 0; i <= n; i++) {
A[i] = true;
}
A[0] = false;
A[1] = false;
int stop = ... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int[] primes = new int[9593];
int ct = 0;
Scanner input = new Scanner(System.in);
int n = 100005;
// initially assume all integers are prime
boolean[] isPrime = new boolean[n + 1... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 505;
vector<int> pnum;
bool vis[100008 + 100];
int mat[maxn][maxn];
void getprime() {
for (int i = 2; i <= 100008; i++) {
if (!vis[i]) {
pnum.push_back(i);
for (int j = i + i; j <= 100008; j += i) {
vis[j] = true;
}
}
}... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codeforces {
/* static int[] prime=new int[5000000+1];
static int[] countfactors=new int[5000000+1];
static void Seive()
{
for(int j=2;j<prime.length;j=j+... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
vector<long long int> isP(2e5 + 1, 1), p;
void fun() {
isP[0] = isP[1] = 0;
long long int i, j;
for (i = 2; i < 2e5 + 1; i++) {
if (isP[i]) {
for (j = 2; j * i <= (2e5); j++) isP[i * j] = 0;
p.push_back(i);
}
}
}
long long int ask(vector<long lon... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | def ints():
return list(map(int,input().split()))
def soe(n):
prime = [1]*(n+1)
p = 2
while(p*p<=n):
if prime[p] == 1:
for i in range(p*2,n+1,p):
prime[i] = 0
p += 1
return prime
p = soe(100500)
p[0] = -1
p[1] = 0
n,m = ints()
l = []
for _ in range(n):
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... |
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
InputReader sc = new InputReader(System.in);
PrintWriter pw = new PrintWriter(System.out);
//precalculated primes
boolean prime[] = new boolean[1000003];
prime[0] = false;
prime[1... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import sys
import math
limit = 100025
list_primes = [True for i in range(limit + 1)]
next_primes = [0 for i in range(200000)]
def SieveOfEratosthenes():
list_primes[0] = list_primes[1] = False
for i in range(2, int(math.sqrt(limit))):
if list_primes[i]:
j = 2
while i * j <= l... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
int vis[N + 2], r[502], c[502];
void init() {
for (int i = 2; i * i <= N; ++i)
if (!vis[i]) {
for (int j = i * i; j <= N; j += i) vis[j] = -1;
}
vis[0] = vis[1] = -1;
for (int i = N; i; --i)
if (vis[i]) vis[i] = vis[i + 1] + 1;
}
i... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.util.Arrays;
import java.util.Scanner;
public class B {
static int[] p;
public static void main(String[] args) {
buildPrime();
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int m = s.nextInt();
int[][] ma = new int[n][m];
for (int i = 0; ... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.io.*;
import java.util.*;
import static java.lang.Math.min;
import static java.lang.Math.max;
public class Code implements Runnable {
public static void main(String[] args) throws IOException {
new Thread(new Code()).start();
}
private void solve() throws IOException {
int n =... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.io.*;
import java.util.*;
public class MainClass {
public static final boolean std = true;
public static final String input = "input.txt";
public static final String output = "output.txt";
public static final int maxn = 100010;
public final Scanner in;
public final PrintWriter out;
public MainCla... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class TaskB_2 {
public static boolean isPrime(int n) {
if (n==1) return false;
int x = (int)Math.sqrt(n);
for(int i = 2; i <= x ; i++) {
if(n%i == 0) {
return false;
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import math,bisect
from collections import Counter,defaultdict
I =lambda:int(input())
M =lambda:map(int,input().split())
LI=lambda:list(map(int,input().split()))
n,m=M()
a=[]
for i in range(n):
b=LI()
a+=[b]
prime=[1]*((10**6)+1)
i=2
while i*i<=10**6:
if prime[i]:
for j in range(i+i,(10**6)+1,i):
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
private final int MAX = 150000;
private int primes[] = new int[M... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | def SieveOfEratosthenes():
n = 100000
prime = [True for i in range(n+1)]
p = 2
while (p * p <= n):
if (prime[p] == True):
for i in range(p * p, n+1, p):
prime[i] = False
p += 1
prime[0] = False
prime[1] = False
return prime
#def SieveOfEratosthenes():
# m = 100001
# n = 100000
# ... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 510;
int a[maxn][maxn];
const int MAXI = 1e5 + 10;
int n, m;
set<long long> prime;
bool isPrime(long long x) {
for (long long i = 2; i * i <= x; i++)
if (x % i == 0) return false;
return x > 1;
}
void make_prime() {
for (int k = 2; k <= MAXI; k++)... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class PrimeMatrix {
static BufferedReader br;
static StringTokenizer st;
static int n, m, pn;
static int[][] a;
static int[] p = new int[... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
int cad[150000];
int n, m;
int matrix[501][501];
int revolution[501][501];
int i, j;
void criba(int n) {
cad[1] = 1;
for (i = 2; i <= n; i++) {
if (cad[i] >= 0) {
for (j = i + i; j < n; j += i) {
cad[j] = 1;
}
}
}
}
int main() {
int i, j, ars, l, vector, meno... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.util.*;
public class cf271b {
public static void main(String[] args) {
int MAX = 100100;
TreeSet<Integer> primes = new TreeSet<Integer>();
boolean[] isPrime = new boolean[MAX];
Arrays.fill(isPrime, true);
isPrime[0] = isPrime[1] = false;
for(int i=0; i<MAX; i++)
if(isPrime[i]... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;
public class P271B_PrimeMatrix {
/**
* @param args
*/
public static void main(String[] args) {
int maxPrime = 9593;
Primes primes = new Primes(maxPrime);
int[] primeNumbers = primes.getPrimes();
InputReader... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #!/usr/bin/python
import io;
import sys;
import math;
from bisect import *;
# IO Method #
def read_int():
return map(int, raw_input().split());
pass
# Binary Search #
def index(a, x):
'Locate the leftmost value exactly equal to x'
i = bisect_left(a, x)
if i != len(a) and a[i] == x:
return i
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | ncrivo = int(10e5)
crivo = [True for i in range(ncrivo)]
crivo[0] = False
crivo[1] = False
for i in range(2, ncrivo):
if crivo[i]:
for j in range(i ** 2, ncrivo, i):
crivo[j] = False
# lendo dados
n, m = map(int, input().split())
data = []
for i in range(n):
data.append(list(map(int, input... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
int vis[maxn];
int q[maxn];
int Map[509][5009];
int sum = 0;
void Prime() {
for (int i = 2; i * i <= maxn; i++) {
for (int j = 2; j <= maxn; j++)
if (!vis[i] && i * j <= maxn) {
vis[i * j] = 1;
}
}
vis[1] = 1;
vis[0] ... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
void getSOE(vector<uint64_t> &p, uint64_t N, const uint64_t &maxval) {
vector<bool> v(N + 1, true);
v[0] = v[1] = false;
for (uint64_t i = 2; i * i <= N; ++i) {
if (!v[i]) continue;
for (uint64_t j = i * i; j <= N; j += i) {
... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayLis... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | import sys
import math
input_file = sys.stdin;
mat = [[0 for _ in xrange(500)] for _ in xrange(500)];
prim = [0 for _ in xrange(10**5 + 1)];
next_prim = [0 for _ in xrange(10**5 + 1)];
prev_prim = [0 for _ in xrange(10**5 + 1)];
def readline():
return input_file.readline();
def is_prim(n):
if n == 1: return ... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | # encoding: utf-8
def makePrimeTable(limit):
isPrime = [True] * (limit)
isPrime[0] = False
isPrime[1] = False
for i in range(2, limit):
if isPrime[i]:
for j in range(i + i, limit, i):
isPrime[j] = False
return isPrime
def makeMinPrimeTable(is_prime):
min_pri... |
Problem: You've got an n Γ m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary number of times.
You are really curious about prime numbers. Let us remind y... | #include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
template <class T>
T power(T a, long long int n) {
T res = 1;
while (n > 0) {
if (n % 2) res = res * a;
a = a * a, n = n / 2;
}
return res;
}
vector<long long int> arr;
;
void SieveOfEratosthenes(int n) {
bool prime[n +... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.