From f1944042f59cec96b8d6cc97decf4eaa1d3c9d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Sat, 21 Oct 2023 14:19:27 +0200 Subject: DN01 --- "\305\241ola/p1/dn/DN00_javniTesti/test01.in" | 2 ++ "\305\241ola/p1/dn/DN01_63230317.java" | 14 ++++++++++++++ "\305\241ola/p1/dn/DN01_javniTesti/test01.in" | 1 + "\305\241ola/p1/dn/DN01_naivno.c" | 21 +++++++++++++++++++++ "\305\241ola/p1/dn/tj.sh" | 27 +++++++++++++++++++++++++++ 5 files changed, 65 insertions(+) create mode 100644 "\305\241ola/p1/dn/DN00_javniTesti/test01.in" create mode 100644 "\305\241ola/p1/dn/DN01_63230317.java" create mode 100644 "\305\241ola/p1/dn/DN01_javniTesti/test01.in" create mode 100644 "\305\241ola/p1/dn/DN01_naivno.c" create mode 100755 "\305\241ola/p1/dn/tj.sh" diff --git "a/\305\241ola/p1/dn/DN00_javniTesti/test01.in" "b/\305\241ola/p1/dn/DN00_javniTesti/test01.in" new file mode 100644 index 0000000..9e9f608 --- /dev/null +++ "b/\305\241ola/p1/dn/DN00_javniTesti/test01.in" @@ -0,0 +1,2 @@ +23 +6 diff --git "a/\305\241ola/p1/dn/DN01_63230317.java" "b/\305\241ola/p1/dn/DN01_63230317.java" new file mode 100644 index 0000000..d7f0659 --- /dev/null +++ "b/\305\241ola/p1/dn/DN01_63230317.java" @@ -0,0 +1,14 @@ +import java.util.*; +public class DN01_63230317 { + public static void main (String[] args) { + Scanner sc = new Scanner(System.in); + int a = sc.nextInt(); + int b = sc.nextInt(); + if (b < a) { + a += b; + b = a-b; + a -= b; + } + System.out.println((a-1)*(a*b)-(a-1)*a/2*(a+b)+(a-1)*a*(2*(a-1)+1)/6); + } +} diff --git "a/\305\241ola/p1/dn/DN01_javniTesti/test01.in" "b/\305\241ola/p1/dn/DN01_javniTesti/test01.in" new file mode 100644 index 0000000..9290688 --- /dev/null +++ "b/\305\241ola/p1/dn/DN01_javniTesti/test01.in" @@ -0,0 +1 @@ +4 6 diff --git "a/\305\241ola/p1/dn/DN01_naivno.c" "b/\305\241ola/p1/dn/DN01_naivno.c" new file mode 100644 index 0000000..ae6547c --- /dev/null +++ "b/\305\241ola/p1/dn/DN01_naivno.c" @@ -0,0 +1,21 @@ +#include +#include +int main (int argc, char ** argv) { + if (argc != 3) { + fprintf(stderr, "%s a b\n", argv[0]); + return 1; + } + int a = atoi(argv[1]); + int b = atoi(argv[2]); + if (b < a) { + int temp = a; + a = b; + b = temp; + } + int sum = 0; + for (int s = 1; s < a; s++) { + fprintf(stderr, "D: %d\ts=%d, a=%d, b=%d\n", (a-s)*(b-s), s, a, b); + sum += (a-s)*(b-s); + } + printf("%d\n", sum); +} diff --git "a/\305\241ola/p1/dn/tj.sh" "b/\305\241ola/p1/dn/tj.sh" new file mode 100755 index 0000000..b883d3e --- /dev/null +++ "b/\305\241ola/p1/dn/tj.sh" @@ -0,0 +1,27 @@ +#!/bin/bash +d=$3 +[ x$d = x ] && d=. +echo "$0 -- Anton Luka Šijanec -- 2023" +echo http://ni.šijanec.eu./sijanec/r/tree/šola/p1/dn/tj.sh +echo +[ x$1 = x ] && { echo kot prvi argument bi morali navesti ime .java datoteke!; exit 1; } +[ x$2 = x ] && { echo kot drugi argument bi morali navesti pot do direktorija s testi!; exit 1; } +uspelih=0 +neuspelih=0 +for f in $2/*.in +do + echo $f + uspeh=0 + /usr/bin/time --quiet -f %E diff --side-by-side <(java $1 < $f) `sed s/in$/out/ <<<$f` && uspeh=1 + if [ $uspeh -eq 0 ] + then + neuspelih=$(($neuspelih+1)) + echo "^^ čas izvajanja NEUSPELO! levo je vaš izhod, desno je pravilen izhod" + else + uspelih=$(($uspelih+1)) + echo "^^^ čas izvajanja USPELO" + fi + echo +done +echo +echo uspešnih testov: $uspelih neuspešnih testov: $neuspelih -- cgit v1.2.3