Skip to content

Commit

Permalink
Add unfinished solution
Browse files Browse the repository at this point in the history
  • Loading branch information
deniscostadsc committed Nov 26, 2024
1 parent 92f33c0 commit 52f42ce
Show file tree
Hide file tree
Showing 8 changed files with 4,625 additions and 46 deletions.
30 changes: 15 additions & 15 deletions solutions/beecrowd/1040/1040.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
int main() {
float a, b, c, d, e, m;

scanf("%f %f %f %f", &a, &b, &c, &d);
while (scanf("%f %f %f %f", &a, &b, &c, &d) != EOF) {
m = (a * 2.0 + b * 3.0 + c * 4.0 + d) / 10.0;

m = (a * 2 + b * 3 + c * 4 + d) / 10;
printf("Media: %.1f\n", ((float)(int)(m*10)/10.0));

printf("Media: %.1f\n", m);
if (m >= 7.0) {
printf("Aluno aprovado.\n");
} else if (m >= 5.0) {
printf("Aluno em exame.\n");

if (m >= 7.0) {
printf("Aluno aprovado.\n");
} else if (m >= 5.0) {
printf("Aluno em exame.\n");
scanf("%f", &e);

scanf("%f", &e);
printf("Nota do exame: %.1f\n", e);

printf("Nota do exame: %.1f\n", e);
if (e + m / 2.0 > 5.0) {
printf("Aluno aprovado.\n");
} else {
printf("Aluno reprovado.\n");
}

if (e + m / 2.0 > 5.0) {
printf("Aluno aprovado.\n");
printf("Media final: %.1f\n", (e + m) / 2.0);
} else {
printf("Aluno reprovado.\n");
}

printf("Media final: %.1f\n", (e + m) / 2.0);
} else {
printf("Aluno reprovado.\n");
}

return 0;
Expand Down
32 changes: 32 additions & 0 deletions solutions/beecrowd/1040/1040.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(ns main
(:require [clojure.string :as str]))

(defn retake-exam [average]
(println "Aluno em exame.")
(let [retake-grade (Double/parseDouble (read-line))
final-average (/ (+ retake-grade average) 2.0)]
(printf "Nota exame: %.1f%n" retake-exam)
(if (> final-average 5.0)
(println "Aluno aprovado.")
(println "Aluno reprovado."))
(printf "Media final: %.1f%n" final-average)))

(defn grade [n1 n2 n3 n4]
(let [average (/ (+ (* n1 2) (* n2 3) (* n3 4) n4) 10)]
(printf "Media: %.1f%n" average)
(cond (>= average 7.0)
(println "Aluno aprovado.")
(>= average 5.0)
(retake-exam average)
:else
(println "Aluno reprovado."))))

(defn main []
(loop [line (read-line)]
(when line
(let [[n1 n2 n3 n4] (->> (str/split line #" ")
(map #(Double/parseDouble %)))]
(grade n1 n2 n3 n4))
(recur (read-line)))))

(main)
30 changes: 15 additions & 15 deletions solutions/beecrowd/1040/1040.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
int main() {
float a, b, c, d, e, m;

scanf("%f %f %f %f", &a, &b, &c, &d);
while (scanf("%f %f %f %f", &a, &b, &c, &d) != EOF) {
m = (a * 2 + b * 3 + c * 4 + d) / 10;

m = (a * 2 + b * 3 + c * 4 + d) / 10;
printf("Media: %.1f\n", m);

printf("Media: %.1f\n", m);
if (m >= 7.0) {
printf("Aluno aprovado.\n");
} else if (m >= 5.0) {
printf("Aluno em exame.\n");

if (m >= 7.0) {
printf("Aluno aprovado.\n");
} else if (m >= 5.0) {
printf("Aluno em exame.\n");
scanf("%f", &e);

scanf("%f", &e);
printf("Nota do exame: %.1f\n", e);

printf("Nota do exame: %.1f\n", e);
if (e + m / 2.0 > 5.0) {
printf("Aluno aprovado.\n");
} else {
printf("Aluno reprovado.\n");
}

if (e + m / 2.0 > 5.0) {
printf("Aluno aprovado.\n");
printf("Media final: %.1f\n", (e + m) / 2.0);
} else {
printf("Aluno reprovado.\n");
}

printf("Media final: %.1f\n", (e + m) / 2.0);
} else {
printf("Aluno reprovado.\n");
}

return 0;
Expand Down
31 changes: 17 additions & 14 deletions solutions/beecrowd/1040/1040.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
n1, n2, n3, n4 = map(float, input().split())
import sys

average = (n1 * 2 + n2 * 3 + n3 * 4 + n4) / 10
for line in sys.stdin:
n1, n2, n3, n4 = map(float, line.split())

print(f'Media: {average:.1f}')
if average >= 7.0:
print('Aluno aprovado.')
elif average >= 5.0:
print('Aluno em exame.')
average = (n1 * 2 + n2 * 3 + n3 * 4 + n4) / 10

final_test = float(input())

print(f'Nota do exame: {final_test:.1f}')
if (final_test + average) / 2.0 > 5.0:
print(f'Media: {average:.1f}')
if average >= 7.0:
print('Aluno aprovado.')
elif average >= 5.0:
print('Aluno em exame.')

final_test = float(input())

print(f'Nota do exame: {final_test:.1f}')
if (final_test + average) / 2.0 > 5.0:
print('Aluno aprovado.')
else:
print('Aluno reprovado.')
print(f'Media final: {(final_test + average) / 2.0:.1f}')
else:
print('Aluno reprovado.')
print(f'Media final: {(final_test + average) / 2.0:.1f}')
else:
print('Aluno reprovado.')
Empty file added solutions/beecrowd/1040/WRONG
Empty file.
29 changes: 29 additions & 0 deletions solutions/beecrowd/1040/generate_in.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

set -euo pipefail

TESTCASES=1000
CURRENT_PATH=$(dirname -- "${BASH_SOURCE[0]}")

function get_random_grade {
if [[ $((RANDOM % 100)) -eq 0 ]]; then
echo "10.0"
else
echo "$((RANDOM % 10)).$((RANDOM % 10))"
fi
}

for i in $(seq "${TESTCASES}"); do
n1=$(get_random_grade)
n2=$(get_random_grade)
n3=$(get_random_grade)
n4=$(get_random_grade)
average_py=$(python3 -c "print(f\"{(${n1} * 2.0 + ${n2} * 3.0 + ${n3} * 4.0 + ${n4}) / 10.0:.1f}\")")

{
echo "${n1} ${n2} ${n3} ${n4}"
if (( $(echo "${average_py} >= 5.0" | bc -l) )) && (( $(echo "${average_py} <= 6.9" | bc -l) )); then
get_random_grade
fi
} >> "${CURRENT_PATH}/in-$(printf "%04d" "${i}")".txt
done
Loading

0 comments on commit 52f42ce

Please sign in to comment.