Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int PRIME = 999983;
const int MOD = 1000000007;
const int MULTI = 1000000007;
const long double EPS = 1e-10;
inline bool isodd(int x) { return x & 1; }
inline bool isodd(long long x) { return x & 1; }
int main(void) {
int n, k;
scanf("%... | CPP |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
if (n * (n - 1) / 2 <= k) {
return cout << "no solution", 0;
}
for (int i = 0; i < 1; i++) {
for (int j = 0; j < n; j++) {
cout << i << " " << j << endl;
}
}
return 0;
}
| CPP |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | n, k = map(int, raw_input().split())
if k >= n*(n-1)/2: print 'no solution'
else:
for i in xrange(n):
print '0 {0}'.format(i) | PYTHON |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class C {
private static StringTokenizer tokenizer;
private static BufferedReader bf;... | JAVA |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException,InterruptedException{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt(),k=sc.nextInt();
pair[] arr=new pair[n];
for (int i = 0; i < n; i++) {
arr[i]=new pair(0,i);
}
Arrays.sort(ar... | JAVA |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class C {
static class Scanner{
BufferedReader br=null;
StringTokenizer tk=null;
public Scanner(){
br=new BufferedReader(new InputStreamReader(System.in));
}
public Str... | JAVA |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | import java.io.*;
public class A {
private BufferedReader reader;
public static void main(String[] args) throws IOException
{
new A().run();
}
StreamTokenizer in;
PrintWriter out;
double nextDouble() throws IOException
{
in.nextToken();
return in.nval;
}
... | JAVA |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | import java.util.Scanner;
public class ClosestPair {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
if(k >= n*(n-1)/2) {
System.out.print("no solution");
} else {
for (int i = ... | JAVA |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author Sanchit M. Bhatnagar (sanchitbhatnagar@gmail.com)
*/
public class Main {
public static void main(St... | JAVA |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
int n = nextInt();
int k = nextInt();
int nows = 0;
int nowf = n / 2 - 1;
if((n * (n - 1) / 2) > k){
for(int i = 0; i < n; i ++){
println(0 + " " + (i + 1));
}
} else {
println("no solution");... | JAVA |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* @author ayush
*
*/
public class... | JAVA |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N = 2e5 + 100;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
;
int x, k;
cin >> x >> k;
if (x * (x - 1) / 2 <= k) {
cout << "no solution\... | CPP |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.StringTokenizer;
public class Balance... | JAVA |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | import java.util.*;
import java.io.*;
public class C {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
/* Find the maximum number for 'tot', which is just n choose 2 */
if (n*(n-1) <= 2*k)
System.out.println("no solution");
els... | JAVA |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
public class C {
static BufferedReader reader;
static StringTokenizer tokenizer;
static PrintWriter writ... | JAVA |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | import sys
inp = sys.stdin.readline() #read line
n, k = map(int, inp.split())
mc = n * ( n - 1 ) / 2
if n == 2:
mc = 1
if mc <= k:
print 'no solution'
else:
for i in xrange(n):
print "%i %i" % (0, i) | PYTHON |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
long long n, k;
int main() {
long long cnt;
while (cin >> n >> k) {
cnt = n * (n - 1) / 2;
if (cnt > k) {
for (int i = 0; i < n; i++) cout << 0 << " " << i << endl;
} else
cout << "no solution" << endl;
}
return 0;
}
| CPP |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | #include <bits/stdc++.h>
int i, j, k, m, n;
int main() {
while (scanf("%d %d", &n, &k) == 2) {
if (k >= n * (n - 1) / 2) {
printf("no solution\n");
continue;
}
for (i = 1; i <= n; i++) printf("0 %d\n", i);
}
return 0;
}
| CPP |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
scanf("%d%d", &n, &k);
if (((n - 1) * n) / 2 <= k) {
printf("no solution\n");
} else {
int ypos = 0;
for (int i = 0; i < n; ++i) {
printf("%d %d\n", i, ypos);
ypos += (n + 1);
}
}
return 0;
}
| CPP |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
string FILE_NAME = "testcase.C";
string NAME;
string itos(int n) {
stringstream ss;
ss << n;
return ss.str();
}
int main() {
int n, k;
cin >> n >> k;
if (k >= n * (n - 1) / 2) {
cout << "no solu... | CPP |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, k;
cin >> n >> k;
if (k >= n * (n - 1) / 2)
cout << "no solution" << endl;
else
for (int i = 1; i <= n; i++) cout << 0 << " " << i << endl;
return 0;
}
| CPP |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | n, k = map(int, input().split())
if k >= n * (n - 1) // 2:
print("no solution")
else:
for i in range(n):
print(i, i * (n + 1))
| PYTHON3 |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
if (k >= n * (n - 1) / 2) {
cout << "no solution";
return 0;
}
for (int i = 1; i <= n; i++) {
cout << 0 << ' ' << i << "\n";
}
return 0;
}
| CPP |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | import java.util.Scanner;
public class C {
static Scanner scanner = new Scanner(System.in);
static int N, K, tot;
public static void main(String[] args) {
N = scanner.nextInt();
K = scanner.nextInt();
tot = N * (N - 1) / 2;
if (tot <= K) {
System.out.println("no solution");
}
else {
for (int i=... | JAVA |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int i, j, k, n, m;
while (cin >> n >> k) {
if (n * (n - 1) / 2 <= k) {
puts("no solution");
} else {
for (i = 0; i < n; i++) printf("0 %d\n", i);
}
}
return 0;
}
| CPP |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | #include <bits/stdc++.h>
struct A {
int x;
int y;
} p[2000];
double d;
double min(double a, double b) {
if (a > b)
return b;
else
return a;
}
double distance(int ax, int ay, int bx, int by) {
return sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
}
int main() {
int i, j, n, k, tot;
scanf("%d ... | CPP |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
if (k >= (n * n - n) / 2)
puts("no solution");
else {
for (int i = 0; i < n; i++) cout << 0 << " " << i << endl;
}
return 0;
}
| CPP |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
using pii = pair<long long, long long>;
const long long INF = 1e18;
void dprint(string s) { cout << "\n"; }
void dprint() { cout << "\n"; }
template <class T, class... U>
void dprint(string s, T t, U... u) {
long long w = s.find(',');
cout << "[" << s.substr(0, w) << ":... | CPP |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
void OMG() { cout << "OMG>.< I don't know!\n"; }
void W1() { cout << "Freda's\n"; }
void W2() { cout << "Rainbow's\n"; }
bool ff1(string S) {
string A = "";
for (int i = 0; i < 5; i++) A += S[i];
return (A == "miao.");
}
bool ff2(string S) {
string A = "";
for (in... | CPP |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | import java.util.Scanner;
public class main {
public static void main(String[] args) {
Scanner cin=new Scanner(System.in);
int n=cin.nextInt(),k=cin.nextInt();
if (n*(n-1)/2>k)
while (n>0){
System.out.println("0 "+n);
n--;
}
el... | JAVA |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int maxN = 2005;
long long n, k, x[maxN] = {-3000}, y[maxN] = {-3000}, ans;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> k;
for (int i = 1; i < n; i++) {
ans += i;
x[i] = x[i - 1];
y[i] = y[i - 1] - 1;
}
if (ans <= ... | CPP |
312_C. The Closest Pair | Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the follows. Given n points in the plane, find a pair of points between... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
static const int INF = 500000000;
template <class T>
void debug(T a, T b) {
for (; a != b; ++a) cerr << *a << ' ';
cerr << endl;
}
int n, k;
int main() {
cin >> n >> k;
int maxi = n * (n - 1) / 2;
if (k >= maxi) {
puts("no solution");
return 0;
}
for (... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | I=lambda:map(int, raw_input().split())
def main():
d={}
s = raw_input()
l = input()
for c in s:
d[c] = d.get(c,0) + 1
if len(d) > l:
print -1
return
lo = 0
hi = 10000
while lo + 1 < hi:
mid = (lo + hi) / 2
c = 0
for x in d.itervalues():
... | PYTHON |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
char s[1001];
int co[200];
int len;
struct p {
char c;
int num;
int ap;
bool operator<(const p& other) const {
int t1, t2;
t1 = num / ap;
if (double(num) / ap > t1) {
t1++;
}
t2 = other.num / other.ap;
if (double(other.num) / other.ap >... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
string s;
int tedad[300];
bool possible(int t, int n) {
int len = 0;
for (int i = 'a'; i <= 'z'; i++) {
len += tedad[i] / t;
if (tedad[i] % t != 0) len++;
}
return len <= n;
}
int bs(int first, int second, int n) {
if (first == second) return first;
int ... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
string a;
int n;
int freq[26] = {0};
cin >> a >> n;
for (int i = 0; i < a.length(); i++) freq[a[i] - 'a']++;
int lo = 1, hi = 1001;
int ans = -1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
int need = 0;
for (int i = 0; i < 26; i++) ... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author Vadim
*/
p... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.io.BufferedReader;
public class Main{
static int[][] grid;
public static void main(String[... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 |
import sys
s = sys.stdin.readline().strip()
n = int(sys.stdin.readline())
d = {}
for i in xrange(len(s)):
if s[i] in d:
d[s[i]] += 1
else:
d[s[i]] = 1
num_letters = len(d.keys())
if num_letters > n:
print '-1'
elif num_letters == n:
print max(d.values())
print ''.join(d.keys())... | PYTHON |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
int j, n, l, i, h, q1, q2, x, y, m, k, t, ans, p1, p2, ans1, ans2, a[1000500],
q, d[1000500], p;
string s, z;
set<char> ss;
void init() {
cin >> s;
n = s.size();
cin >> k;
}
void solve() {
for (j = 1; j <= n; j++) {
... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.*;
import java.util.*;
public class Banana {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
int n = sc.nextInt();
TreeMap<Character, Integer> tm = new TreeMap<Character, Integer>();
for (int i = 0; i < ... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
string s;
int n;
int cnt[256];
bool check(int x) {
if (x == 0) return false;
int sum = 0;
for (char c = 'a'; c <= 'z'; ++c) {
int d = cnt[c] / x + !!(cnt[c] % x);
sum += d;
}
return sum <= n;
}
string get(int x) {
string t = "";
for (char c = 'a'; c <=... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class Banana {
public static boolean can(int []a,int n,int len)
{
int needed=0;
for(int x:a)
{
if(x!=... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.util.*;
import java.lang.reflect.Array;
import java.math.*;
import java.io.*;
public class main{
static Scanner scan = new Scanner(new BufferedInputStream(System.in));
public static void main(String[] args){
while(scan.hasNext()){
int[][] a = new int[2][26];
String str = scan.nextLine();
int n... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
string s;
cin >> s >> n;
set<char> se(s.begin(), s.end());
if ((int)se.size() > n) {
cout << "-1"
<< "\n";
} else {
string str;
map<char, int> x, y;
for (int i =... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
set<char> st;
int a[26] = {0};
int main() {
int n;
string s;
cin >> s >> n;
for (auto c : s) {
st.insert(c);
a[c - 97]++;
}
if ((int)st.size() > n) {
printf("-1\n");
return 0;
}
for (int i = 1; i <= 1000; ++i) {
int co = 0;
for (int j... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
template <class T>
void PV(T a, T b) {
while (a != b) cout << *a++ << " ";
cout << endl;
}
template <class T>
inline bool chmin(T &a, T b) {
return a > b ? a = b, 1 : 0;
}
template <class T>
inline bool chmax(T &a, T b) {
return a < b ? a = b, 1 : 0;
}
const int inf... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
string s;
int n;
int cnt[256];
bool check(int x) {
int sum = 0;
for (char c = 'a'; c <= 'z'; ++c) {
int d = cnt[c] / x + !!(cnt[c] % x);
sum += d;
}
return sum <= n;
}
string get(int x) {
string t = "";
for (char c = 'a'; c <= 'z'; ++c) {
int d = cnt... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
string S;
int N, L;
map<char, int> ch;
void read();
void solve();
bool test(int);
void howdy(int);
int main() {
read();
solve();
return 0;
}
void read() { cin >> S >> N, L = int(S.length()); }
void solve() {
for (int i = 0; i < L; ++i) ++ch[S[i]];
if (int(ch.size(... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | '''
http://codeforces.com/contest/335/problem/A
'''
from collections import Counter
char_counter = dict(Counter(raw_input().strip()))
n = int(raw_input())
result = ""
index = 1
if len(char_counter) > n: print -1
else:
while True:
for key, value in char_counter.iteritems():
if value % index == 0... | PYTHON |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | //package memsql.r2;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class A {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve()
{
char[] s = ns(2000... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | s = input()
n = int(input())
symb_cnt = {}
for c in s:
symb_cnt[c] = symb_cnt[c] + 1 if c in symb_cnt else 1
for cnt in range(1, len(s) + 1):
s1 = ""
for c in symb_cnt:
s1 += c * ((symb_cnt[c] + cnt - 1) // cnt)
if len(s1) <= n:
for i in range(n - len(s1)):
s1 += 'a'
print(cnt)
print(s1)
exit(0)
print... | PYTHON3 |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n;
string str;
map<char, int> mp;
set<char> st;
bool ok(int k) {
int rem = n - int((st).size());
for (auto it = st.begin(); it != st.end(); it++) {
char c = *it;
int r = mp[c] - k;
if (r <= 0) continue;
int need = (r + k - 1) / k;
if (need > rem)... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int Up(int a, int b) { return (a + b - 1) / b; }
class Type {
public:
char ch;
int number;
int k;
int value;
Type() {}
Type(char _ch, int _number) : ch(_ch), number(_number), k(0) {}
friend bool operator<(const Type& a, const Type& b) {
return a.number < ... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
string s;
int c[26];
bool check(int m, string t) {}
bool solve() {
int l = 1, r = 10000;
while (l <= r) {
}
}
bool compare(pair<char, int> a, pair<char, int> b) {
return a.second > b.second;
}
int main() {
cin >> s;
int n;
cin >> n;
unordered_set<char> st;
... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
string s;
int n;
int cnt[256];
bool check(int x) {
if (x == 0) return false;
int sum = 0;
for (char c = 'a'; c <= 'z'; ++c) {
int d = cnt[c] / x + !!(cnt[c] % x);
sum += d;
}
return sum <= n;
}
string get(int x) {
string t = "";
for (char c = 'a'; c <=... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int am[27];
int dp[27][1010];
int path[27][1010];
int call(int p, int n) {
if (p == 26) return (n == 0 ? 0 : (1 << 29));
int &ret = dp[p][n];
if (ret != -1) return ret;
int &ppp = path[p][n];
ret = (1 << 29);
if (!am[p]) {
ret = call(p + 1, n);
ppp = 0;
... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int a[27], c[27], d[27];
int main() {
int count, i, n, max, co, t, index, k;
char str[1010], ch, b[1010];
ch = getchar();
while (ch != '\n') {
a[ch - 'a' + 1]++;
ch = getchar();
}
count = 0;
for (i = 1; i <= 26; i++)
if (a[i] != 0) count++;
scanf... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class A {
public static void main(String[] args) throws IOException {
PrintWriter out = new PrintWriter(System.out);
BufferedReader br = ... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public stat... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.util.*;
import java.io.*;
public class A
{
public static void main(String ar[]) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
char c[]=br.readLine().toCharArray();
int n=c.length;
int m=Integer.parseInt(... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.InputMismatchException;
import java.util.HashMap;
import java.util.Set;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.StringTokenizer;
im... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | def ceil(a,b):
return (a+b-1)/b
s = raw_input()
n = input()
cnts = {}
for l in set(s): cnts[l] = s.count(l)
if len(cnts) > n:
print -1
raise SystemExit
for i in range(1,1001):
tot = 0
for (l, c) in cnts.items():
tot += ceil(c,i)
if tot <= n:
print i
out = ''
for (l, c) in cnts.items():
out += l*ceil... | PYTHON |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | from collections import Counter
from math import ceil
s = raw_input()
c = Counter(s)
n = int(raw_input())
if n < len(c):
print -1
else:
d = {l: 1 for l in c}
for _ in range(n - len(c)):
_, l = max([(float(c[l]) / d[l], l) for l in c])
d[l] += 1
print int(max(ceil(float(c[l]) / d[l]) for... | PYTHON |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.PrintWriter;
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
PrintWriter out=new PrintWriter(System.out);
char a[]=sc.next().toCharArray();
int fre[]=new int[26];
int n=a.length;
int ... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
template <class F, class T>
T convert(F a, int p = -1) {
stringstream ss;
if (p >= 0) ss << fixed << setprecision(p);
ss << a;
T r;
ss >> r;
return r;
}
template <class T>
void db(T a, int p = -1) {
if (p >= 0) cout << fixed << setprecision(p);
cout << a << ... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 |
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.InputStream;
import java.util.ArrayList;
public class Main {
public static void mai... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int ceil_div(int a, int b) { return (a + b - 1) / b; }
int main() {
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
string s;
cin >> s;
int n;
cin >> n;
set<char> st(s.begin(), s.end());
if (n < st.size()) {
cout << -1 << endl;
return 0;
}... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import math
def onetry(p, tr):
m = 0
for k in p.keys():
nm = int(math.ceil((p[k]+0.)/tr[k]))
if nm > m:
m = nm
mk = k
return (m, mk)
if __name__=="__main__":
s = raw_input()
n = int(raw_input())
p = {}
for i in range(len(s)):
try:
p[s[i]] += 1
except:
p[s[i]] = 1... | PYTHON |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
struct lett {
char let;
int nb;
int at;
};
int main() {
int values[26], offset = static_cast<int>('a'), total;
lett letts[26];
string str;
cin >> str;
for (int i = 0; i < 26; i++) {
values[i] = 0;
}
for (int i = 0; i < str.length(); i++) {
values... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import math
from fractions import Decimal
S=input()
N=int(input())
Srep={}
ansrep={}
for item in "abcdefghijklmnopqrstuvwxyz":
Srep[item]=0
ansrep[item]=0
for item in S:
Srep[item]+=1
ansrep[item]+=1
Q=list(set(S))
if(len(Q)>N):
print(-1)
else:
n=len(Q)
ans=list(S)
num=1
req=1
... | PYTHON3 |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
int dblcmp(double d) {
if (fabs(d) < eps) return 0;
return d > eps ? 1 : -1;
}
const double PI = 3.1415926535897932384626433832795;
const double pi = acos(-1.0);
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
long long pov(long long a, lo... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 9;
long long gcd(long long a, long long b) {
if (b == 0) return b;
return gcd(b, a % b) + a / b;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
string s;
cin >> s;
int n;
cin >> n;
vector<pair<int, int>> a(26);
for (int i = 0; ... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int i, j, n, m, k, v[30];
string s;
int main() {
cin >> s >> n;
for (i = 0; i < s.size(); i++) v[s[i] - 'a']++;
for (k = 1; k <= s.size(); k++) {
m = 0;
for (i = 0; i < 26; i++) m += ceil(v[i] / (double)k);
if (m <= n) {
cout << k << "\n";
for ... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
namespace p335ABanana {
void solve(int test_num) {
int cnt[26] = {0};
string str;
int n;
cin >> str >> n;
for (int i = 0; i < (int)str.size(); i++) cnt[str[i] - 'a']++;
for (int res = 1; res <= 1000; res++) {
int need = 0;
for (int c = 0; c < 26; c++) ne... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int v[10001];
int main() {
string s;
int n, i, j, k, m, o, p;
cin >> s >> n;
o = s.length();
for (i = 0; i < o; i++) {
v[s[i] - 'a']++;
}
for (i = 1; i <= 1000; i++) {
string ans = "";
for (j = 0; j < 26; j++) {
if (v[j]) {
int y = (v... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.List;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.NoSuchElemen... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
string s;
int coos;
map<char, int> cnt;
string getcoos(int nos) {
string p = "";
for (auto y : cnt) {
int t = (y.second + nos - 1) / nos;
for (int j = 0; j < t; j++) p += (char)(y.first);
}
return p;
}
int main() {
cin >> s;
cin >> coos;
int n = s.size... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
long long int n;
cin >> n;
long long int size = s.length();
vector<long long int> freq(26, 0);
for (long long int i = 0; i < size; i++) {
freq[s[i] - 'a']++;
}
long long int diff = 0;
for (long long int i = 0; i < 26;... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
;
string s, t;
long long n, i;
cin >> s;
cin >> n;
set<pair<double, char>> m;
map<char, long long> freq, c;
for (i = 0; i < s.length(); ++i) {
freq[s[i]]++;
}
for ... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
char s[2000];
int u[30], n, i, ans, l, r, c, j;
int main() {
scanf("%s%d", &s, &n);
for (i = 0; s[i]; i++) u[s[i] - 'a']++;
l = 1;
r = 414141;
while (l < r) {
c = (l + r) / 2;
ans = 0;
for (i = 0; i < 26; i++) ans += (u[i] + c - 1) / c;
if (ans > n... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
char s[1010];
int n;
int cnt[26];
inline bool check(int m) {
int all = 0;
for (int i = 0; i < 26; ++i) all += (int)ceil(1.0 * cnt[i] / m);
return all <= n;
}
int main() {
scanf("%s%d", s, &n);
int len = strlen(s);
for (int i = 0; i < len; ++i) cnt[s[i] - 'a']++;... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.util.Arrays;
import java.util.Scanner;
public class A {
static int[] freq = new int[26];
static int[][] dp;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.next();
int n = in.nextInt();
for (int i = 0; i < s.length... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const double EPS = 1e-6;
int main() {
char s[1005];
scanf("%s", s);
int n;
scanf("%d", &n);
int len = strlen(s);
int cnt[26] = {0};
for (int i = 0; i < len; i++) cnt[s[i] - 'a']++;
bool found = false;
for (int res = 1; re... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | s = input()
n = int(input())
d = {}
r = 0
for a in s:
d.setdefault(a, 0)
d[a] += 1
if(d[a] > r):
r = d[a]
if (len(d) > n):
print(-1)
else:
l = 0
while r - l > 1:
k = (l + r) // 2
cur = 0
for x in d.values():
cur += (x+k-1) // k
if cur > n:
... | PYTHON3 |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
int main() {
std::string s;
int n;
std::cin >> s >> n;
std::vector<int> v(26, 0);
for (auto &c : s) {
v[c - 'a']++;
}
for (std::size_t i = 1; i <= s.size(); i++) {
int need = 0;
for (auto &m : v) {
need += (m + i - 1) / i;
}
if (need <= n) {
std::st... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
public class Banana {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
int ... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | s = input()
n = int(input())
freq = [0 for i in range(0, 300)]
raport = [0 for i in range(0, 300)]
differentLetters = 0
tickets = 0
sol = ''
for c in s: freq[ord(c)] += 1
for i in freq:
if i > 0: differentLetters += 1
if differentLetters > n:
print('-1')
exit()
for i in 'abcdefghijklmnopqrstuvwxyz':
... | PYTHON3 |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int cn['z' + 1], ans, n;
string s, res;
int main() {
cin >> s;
scanf("%ld", &n);
ans = -1;
for (int i = 0; i <= s.length() - 1; i++) cn[s[i]]++;
for (int i = 1; i <= s.length(); i++) {
res = "";
for (int j = 'a'; j <= 'z'; j++)
if (cn[j]) {
i... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n;
int freq[26], filled[26];
vector<pair<int, int> > vfreq;
bool good(int x) {
int sfilled = 0;
for (int i = 0; i < 26; i++) {
filled[i] = (freq[i] + x - 1) / x;
sfilled += filled[i];
}
if (sfilled <= n) return true;
return false;
}
int main() {
stri... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n;
string str;
map<char, int> num;
void print(char x, int y) {
for (int i = 0; i < y; i++) {
cout << x;
}
}
bool check(double x) {
int s = 0;
for (auto tmp : num) {
s += ceil(tmp.second / x);
}
if (s <= n) {
return true;
}
return false;
}
voi... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n, m;
char s[1001];
int main() {
scanf("%s%d", s, &n);
m = strlen(s);
vector<int> c(26, 0);
for (int i = 0; i < m; ++i) {
c[s[i] - 'a'] += 1;
}
m = 0;
for (int i = 0; i < 26; ++i) {
if (c[i] > 0) {
m += 1;
}
}
if (m > n) {
printf(... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.util.Scanner;
import java.util.Map;
import java.io.IOException;
import java.util.HashMap;
import java.util.Set;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author BSRK Aditya
*/
public class Ma... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int freq[30];
int mx, n;
bool check(int x) {
int cnt = 0;
for (int i = 0; i < 30; i++) {
cnt += ceil((double)freq[i] / x);
}
if (cnt <= n) return true;
return false;
}
int main() {
string s;
cin >> s;
int len = s.size();
int cnt = 0;
for (int i = 0; ... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
int main() {
const long N = 26;
std::string s;
std::cin >> s;
std::vector<long> a(N, 0);
long unique(0);
for (long p = 0; p < s.size(); p++) {
if (!a[s[p] - 'a']) {
++unique;
}
++a[s[p] - 'a'];
}
long n;
std::cin >> n;
if (n < unique) {
puts("-1");
... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
public class Main{
static Scanner scan = new Scanner(new BufferedInputStream(System.in));
public static void main(String[] args){
while(scan.hasNext()){
int[][] a = new int[2][26];
String str = scan.ne... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
void data() {
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
}
char s[1100];
int su[27];
int k;
int jd(int n) {
int cnt = 0;
for (int i = 0; i < (26); ++i) {
cnt += (su[i] + n - 1) / n;
}
if (cnt <= k)
return 1;
else
return 0;
}
... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
/**
* @param args
*/
static char str[];
static int count[] = new int[26];
static int length;
static BufferedReader read =... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import sys
s = raw_input()
n = input()
d = [0] * 40
for i in s:
d[ord(i) - 97] += 1
sn = len(filter(lambda x: x > 0, d))
if n < sn:
print -1
else:
for ans in xrange(1, len(s) + 1):
tmp = 0
for i in xrange(40):
tmp += (d[i] + ans - 1) / ans
if tmp <= n:
cnt = 0
print ans
for i in xrange(40):
... | PYTHON |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
char s[1005];
int n;
char ans[1004];
int cnt[40];
bool check(int num) {
int c = 0;
for (int i = 0; i < 40; i++)
if (cnt[i] > 0) c += cnt[i] / num + (cnt[i] % num != 0);
return c <= n;
}
int main() {
scanf("%s", s);
scanf("%d", &n);
int len = strlen(s);
for... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.