Skip to content

Commit

Permalink
Add solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
l3v11 committed Aug 28, 2023
1 parent 96abc8c commit 7f5e929
Show file tree
Hide file tree
Showing 7 changed files with 209 additions and 0 deletions.
21 changes: 21 additions & 0 deletions 1367A. Short Substrings.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {

int n;
scanf("%d", &n);

char str[1001];
while (n--) {
scanf("%s", str);

for (int i=0; i<strlen(str); i+=2) {
printf("%c", str[i]);
}
printf("%c\n", str[strlen(str) - 1]);
}

return 0;
}
27 changes: 27 additions & 0 deletions 1703A. YES or YES.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int main() {

int tc;
scanf("%d", &tc);

char str[4];
while (tc--) {
scanf("%s", str);

for (int i=0; i<strlen(str); i++) {
str[i] = tolower(str[i]);
}

if ((strcmp(str, "yes") == 0)) {
printf("YES\n");
} else {
printf("NO\n");
}
}

return 0;
}
37 changes: 37 additions & 0 deletions 1742A. Sum.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <stdio.h>
#include <stdlib.h>

void sort_array(int arr[], int size) {
for (int i=0; i<size; i++) {
for (int j=i+1; j<size; j++) {
if (arr[i] > arr[j]) {
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
}
}
}

int main() {

int tc;
scanf("%d", &tc);

while (tc--) {
int n[3];
for (int i=0; i<3; i++) {
scanf("%d", &n[i]);
}

sort_array(n, 3);

if (n[0] + n[1] == n[2]) {
printf("YES\n");
} else {
printf("NO\n");
}
}

return 0;
}
47 changes: 47 additions & 0 deletions 1742B. Increasing.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <stdio.h>
#include <stdlib.h>

void sort_array(int arr[], int size) {
for (int i=0; i<size; i++) {
for (int j=i+1; j<size; j++) {
if (arr[i] > arr[j]) {
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
}
}
}

int main() {

int tc;
scanf("%d", &tc);

while (tc--) {
int n;
scanf("%d", &n);

int a[n];
for (int i=0; i<n; i++) {
scanf("%d", &a[i]);
}

sort_array(a, n);

int chk = 0;
for (int i=0; i<n; i++) {
if (a[i] == a[i+1]) {
chk = 1;
}
}

if (chk) {
printf("NO\n");
} else {
printf("YES\n");
}
}

return 0;
}
27 changes: 27 additions & 0 deletions 32B. Borze.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {

char str[201], str_out[201];
scanf("%s", str);

for (int i=0; i<strlen(str); i++) {
if (str[i] == '.') {
strcat(str_out, "0");
}
if (str[i] == '-' && str[i+1] == '.') {
strcat(str_out, "1");
i++;
}
if (str[i] == '-' && str[i+1] == '-') {
strcat(str_out, "2");
i++;
}
}

printf("%s\n", str_out);

return 0;
}
12 changes: 12 additions & 0 deletions 630A. Again Twenty Five!.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <stdio.h>
#include <stdlib.h>

int main() {

long long int n;
scanf("%lld", &n);

printf("25\n");

return 0;
}
38 changes: 38 additions & 0 deletions 758A. Holiday Of Equality.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <stdio.h>
#include <stdlib.h>

void sort_array(int arr[], int size) {
for (int i=0; i<size; i++) {
for (int j=i+1; j<size; j++) {
if (arr[i] > arr[j]) {
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
}
}
}

int main() {

int tc;
scanf("%d", &tc);

int a[tc];
for (int i=0; i<tc; i++) {
scanf("%d", &a[i]);
}

sort_array(a, tc);

int sum=0;
for (int i=0; i<tc; i++) {
if (a[i] < a[tc-1]) {
sum += a[tc-1] - a[i];
}
}

printf("%d\n", sum);

return 0;
}

0 comments on commit 7f5e929

Please sign in to comment.