Moved kattis from Uni repo
This commit is contained in:
1
kattis/problems/02_11_23/cprnummer/1.in
Normal file
1
kattis/problems/02_11_23/cprnummer/1.in
Normal file
@ -0,0 +1 @@
|
||||
070761-4285
|
1
kattis/problems/02_11_23/cprnummer/2.in
Normal file
1
kattis/problems/02_11_23/cprnummer/2.in
Normal file
@ -0,0 +1 @@
|
||||
051002-4321
|
1
kattis/problems/02_11_23/cprnummer/3.in
Normal file
1
kattis/problems/02_11_23/cprnummer/3.in
Normal file
@ -0,0 +1 @@
|
||||
310111-0469
|
28
kattis/problems/02_11_23/cprnummer/main.c
Normal file
28
kattis/problems/02_11_23/cprnummer/main.c
Normal file
@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// Do with scanf
|
||||
|
||||
int values[10] = {4, 3, 2, 7, 6, 5, 4, 3, 2, 1};
|
||||
int sum = 0;
|
||||
for (int i=0; i<10; i++) {
|
||||
char s;
|
||||
if ((s = getchar()) == '-') {
|
||||
i--;
|
||||
continue;
|
||||
} else {
|
||||
sum += (s - '0') * values[i];
|
||||
}
|
||||
|
||||
}
|
||||
printf("Sum: %d\n", sum);
|
||||
|
||||
if (sum % 11 == 0) {
|
||||
printf("1\n");
|
||||
} else {
|
||||
printf("0\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
28
kattis/problems/02_11_23/cprnummer/main.c.orig
Normal file
28
kattis/problems/02_11_23/cprnummer/main.c.orig
Normal file
@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// Do with scanf
|
||||
|
||||
int values[10] = {4, 3, 2, 7, 6, 5, 4, 3, 2, 1};
|
||||
int sum = 0;
|
||||
for (int i=0; i<10; i++) {
|
||||
char s;
|
||||
if ((s = getchar()) == '-') {
|
||||
i--;
|
||||
continue;
|
||||
} else {
|
||||
sum += (s - '0') * values[i];
|
||||
}
|
||||
|
||||
}
|
||||
printf("Sum: %d\n", sum);
|
||||
|
||||
if (sum % 11 == 0) {
|
||||
printf("1\n");
|
||||
} else {
|
||||
printf("0\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
11
kattis/problems/02_11_23/cprnummer/main.py
Normal file
11
kattis/problems/02_11_23/cprnummer/main.py
Normal file
@ -0,0 +1,11 @@
|
||||
lol = input().replace("-", "")
|
||||
values = [4, 3, 2, 7, 6, 5, 4, 3, 2, 1];
|
||||
|
||||
sum = 0
|
||||
for i in range(10):
|
||||
sum += int(lol[i]) * values[i]
|
||||
|
||||
if sum % 11 == 0:
|
||||
print(1)
|
||||
else:
|
||||
print(0)
|
BIN
kattis/problems/02_11_23/cprnummer/program
Executable file
BIN
kattis/problems/02_11_23/cprnummer/program
Executable file
Binary file not shown.
7
kattis/problems/02_11_23/horror/1.in
Normal file
7
kattis/problems/02_11_23/horror/1.in
Normal file
@ -0,0 +1,7 @@
|
||||
6 3 5
|
||||
0 5 2
|
||||
0 1
|
||||
1 2
|
||||
4 5
|
||||
3 5
|
||||
0 2
|
5
kattis/problems/02_11_23/horror/2.in
Normal file
5
kattis/problems/02_11_23/horror/2.in
Normal file
@ -0,0 +1,5 @@
|
||||
6 2 3
|
||||
5 2
|
||||
0 5
|
||||
0 1
|
||||
3 4
|
48
kattis/problems/02_11_23/horror/main.c
Normal file
48
kattis/problems/02_11_23/horror/main.c
Normal file
@ -0,0 +1,48 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void printArr(int *arr, int n) {
|
||||
for (int i=0; i<n; i++) {
|
||||
printf("%d ", arr[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void fillArr(int *arr, int n, int val) {
|
||||
for (int i=0; i<n; i++) {
|
||||
arr[i] = val;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int n, h, l;
|
||||
scanf("%d %d %d", &n, &h, &l);
|
||||
|
||||
int ids[1000];
|
||||
for (int i=0; i<h; i++) {
|
||||
scanf("%d", &ids[i]);
|
||||
}
|
||||
printArr(ids, h);
|
||||
|
||||
int freq[1001];
|
||||
fillArr(freq, 1000, -1);
|
||||
|
||||
for (int i=0; i<l; i++) {
|
||||
int a, b;
|
||||
scanf("%d %d", &a, &b);
|
||||
int old_a = freq[a];
|
||||
if (freq[a] == -1) {
|
||||
freq[a] = 0;
|
||||
}
|
||||
if (freq[b] == -1) {
|
||||
freq[b] = 0;
|
||||
}
|
||||
freq[a] += freq[b] + 1;
|
||||
freq[b] += old_a + 1;
|
||||
}
|
||||
|
||||
printArr(freq, n+1);
|
||||
|
||||
return 0;
|
||||
}
|
34
kattis/problems/02_11_23/horror/main.c.orig
Normal file
34
kattis/problems/02_11_23/horror/main.c.orig
Normal file
@ -0,0 +1,34 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void printArr(int *arr, int n) {
|
||||
for (int i=0; i<n; i++) {
|
||||
printf("%d ", arr[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int n, h, l;
|
||||
scanf("%d %d %d", &n, &h, &l);
|
||||
|
||||
int ids[1000];
|
||||
for (int i=0; i<h; i++) {
|
||||
scanf("%d", &ids[i]);
|
||||
}
|
||||
|
||||
int freq[1001];
|
||||
for (int i=0; i<l; i++) {
|
||||
int a,b;
|
||||
scanf("%d %d", &a, &b);
|
||||
int old_a = freq[a];
|
||||
freq[a] += freq[b] + 1;
|
||||
freq[b] += old_a + 1;
|
||||
}
|
||||
|
||||
printArr(freq, n+1);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
4
kattis/problems/02_11_23/horror/main.py
Normal file
4
kattis/problems/02_11_23/horror/main.py
Normal file
@ -0,0 +1,4 @@
|
||||
n, h, l = map(int, input().split(" "))
|
||||
horrors = list(map(int, input().split(" ")))
|
||||
|
||||
ids = [x for x in range(h)]
|
BIN
kattis/problems/02_11_23/horror/program
Executable file
BIN
kattis/problems/02_11_23/horror/program
Executable file
Binary file not shown.
26
kattis/problems/02_11_23/knotknowledge/main.c
Normal file
26
kattis/problems/02_11_23/knotknowledge/main.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n;
|
||||
scanf("%d", &n);
|
||||
|
||||
int sum = 0;
|
||||
|
||||
for (int i=0; i<n; i++) {
|
||||
int temp;
|
||||
scanf("%d", &temp);
|
||||
sum += temp;
|
||||
}
|
||||
|
||||
int otherSum = 0;
|
||||
for (int i=0; i<n-1; i++) {
|
||||
int temp;
|
||||
scanf("%d", &temp);
|
||||
otherSum += temp;
|
||||
}
|
||||
|
||||
printf("%d\n", sum - otherSum);
|
||||
|
||||
return 0;
|
||||
}
|
31
kattis/problems/02_11_23/shopaholic/main.c
Normal file
31
kattis/problems/02_11_23/shopaholic/main.c
Normal file
@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Compare in order to sort from largest to smallest
|
||||
int compare(const void *a, const void *b) {
|
||||
return *(int *)b - *(int *)a;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n;
|
||||
scanf("%d", &n);
|
||||
|
||||
int prices[200001];
|
||||
|
||||
for (int i=0; i<n; i++) {
|
||||
scanf("%d", &prices[i]);
|
||||
}
|
||||
|
||||
long long sum = 0;
|
||||
|
||||
qsort(prices, n, sizeof(int), compare);
|
||||
for (int i=2; i<n; i+=3) {
|
||||
sum += prices[i];
|
||||
}
|
||||
|
||||
printf("%lld\n", sum);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
30
kattis/problems/02_11_23/shopaholic/main.c.orig
Normal file
30
kattis/problems/02_11_23/shopaholic/main.c.orig
Normal file
@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Compare in order to sort from largest to smallest
|
||||
int compare(const void *a, const void *b) {
|
||||
return *(int*)b - *(int*)a;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int n;
|
||||
scanf("%d", &n);
|
||||
|
||||
int *prices = malloc(sizeof(int) * n);
|
||||
|
||||
for (int i=0; i<n; i++) {
|
||||
scanf("%d", &prices[i]);
|
||||
}
|
||||
|
||||
int sum = 0;
|
||||
|
||||
qsort(prices, n, sizeof(int), compare);
|
||||
for (int i=2; i<n; i+=3) {
|
||||
sum += prices[i];
|
||||
}
|
||||
|
||||
printf("%d\n", sum);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
BIN
kattis/problems/02_11_23/shopaholic/program
Executable file
BIN
kattis/problems/02_11_23/shopaholic/program
Executable file
Binary file not shown.
9
kattis/problems/02_11_23/trianglearea/main.c
Normal file
9
kattis/problems/02_11_23/trianglearea/main.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int h, b;
|
||||
scanf("%d %d", &h, &b);
|
||||
|
||||
printf("%f\n", (h*b)/2.0);
|
||||
}
|
BIN
kattis/problems/02_11_23/trianglearea/program
Executable file
BIN
kattis/problems/02_11_23/trianglearea/program
Executable file
Binary file not shown.
11
kattis/problems/02_11_23/universityzoning/main.c
Normal file
11
kattis/problems/02_11_23/universityzoning/main.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int r, c, s, f, t, g;
|
||||
scanf("%d %d %d %d %d %d", &r, &c, &s, &f, &t, &g);
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user