Moved kattis from Uni repo

This commit is contained in:
2023-12-01 13:35:13 +01:00
parent 28a6b807a3
commit aaa2c123b8
164 changed files with 3008 additions and 0 deletions

View File

@ -0,0 +1 @@
070761-4285

View File

@ -0,0 +1 @@
051002-4321

View File

@ -0,0 +1 @@
310111-0469

View 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;
}

View 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;
}

View 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)

Binary file not shown.

View File

@ -0,0 +1,7 @@
6 3 5
0 5 2
0 1
1 2
4 5
3 5
0 2

View File

@ -0,0 +1,5 @@
6 2 3
5 2
0 5
0 1
3 4

View 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;
}

View 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;
}

View 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)]

Binary file not shown.

View 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;
}

View 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;
}

View 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;
}

Binary file not shown.

View 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);
}

Binary file not shown.

View 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;
}