1
0
Fork 0

Guess my rank is gonna plummet again

This commit is contained in:
Nguyễn Gia Phong 2019-03-13 09:13:11 +07:00
parent 477c426b55
commit 86fd670f4d
4 changed files with 60 additions and 0 deletions

14
codechef/chdiger.py Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env python3
for _ in range(int(input())):
n, d = input().split()
n, d = [int(x) for x in n], int(d)
for i in range(-1, -1-len(n), -1):
if n[i] > d:
n[i] = d
else:
break
for i in range(i, -len(n), -1):
if n[i] < n[i-1]:
n.pop(i - 1)
n.append(d)
print(''.join(map(str, n)))

7
codechef/chnum.py Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env python3
from collections import Counter
for _ in range(int(input())):
input()
sizes = Counter(z // abs(z) for z in map(int, input().split())).values()
print(max(sizes), min(sizes))

33
codechef/jain.c Normal file
View File

@ -0,0 +1,33 @@
#include <stdio.h>
const char VOWELS[] = {97, 101, 105, 111, 117};
int main()
{
char *c, s[1001];
long t, n, i, j, tmp;
scanf("%ld", &t);
while (t--) {
long vowels[32] = {};
scanf("%ld", &n);
for (i = 0; i < n; ++i) {
tmp = 0;
scanf("%s", &s);
for (c = s; *c; ++c) {
for (j = 0; VOWELS[j] ^ *c; ++j);
tmp |= 1 << j;
}
++vowels[tmp];
}
tmp = vowels[31] * (vowels[31] - 1) / 2;
for (i = 0; i < 31; ++i)
for (j = i + 1; j < 32; ++j)
tmp += ((i | j) == 31) * vowels[i] * vowels[j];
printf("%ld\n", tmp);
}
return 0;
}

6
codechef/jain.py Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env python3
from itertools import combinations
for _ in range(int(input())):
print(sum(len(a | b) == 5 for a, b in combinations(
(set(input()) for d in range(int(input()))), 2)))