diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2023-10-21 14:19:27 +0200 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2023-10-21 14:19:27 +0200 |
commit | f1944042f59cec96b8d6cc97decf4eaa1d3c9d4a (patch) | |
tree | e701c119fc8541e41c48021636897c3aa393cd0f | |
parent | vaje (diff) | |
download | r-f1944042f59cec96b8d6cc97decf4eaa1d3c9d4a.tar r-f1944042f59cec96b8d6cc97decf4eaa1d3c9d4a.tar.gz r-f1944042f59cec96b8d6cc97decf4eaa1d3c9d4a.tar.bz2 r-f1944042f59cec96b8d6cc97decf4eaa1d3c9d4a.tar.lz r-f1944042f59cec96b8d6cc97decf4eaa1d3c9d4a.tar.xz r-f1944042f59cec96b8d6cc97decf4eaa1d3c9d4a.tar.zst r-f1944042f59cec96b8d6cc97decf4eaa1d3c9d4a.zip |
-rw-r--r-- | šola/p1/dn/DN00_javniTesti/test01.in | 2 | ||||
-rw-r--r-- | šola/p1/dn/DN01_63230317.java | 14 | ||||
-rw-r--r-- | šola/p1/dn/DN01_javniTesti/test01.in | 1 | ||||
-rw-r--r-- | šola/p1/dn/DN01_naivno.c | 21 | ||||
-rwxr-xr-x | šola/p1/dn/tj.sh | 27 |
5 files changed, 65 insertions, 0 deletions
diff --git a/šola/p1/dn/DN00_javniTesti/test01.in b/šola/p1/dn/DN00_javniTesti/test01.in new file mode 100644 index 0000000..9e9f608 --- /dev/null +++ b/šola/p1/dn/DN00_javniTesti/test01.in @@ -0,0 +1,2 @@ +23 +6 diff --git a/šola/p1/dn/DN01_63230317.java b/šola/p1/dn/DN01_63230317.java new file mode 100644 index 0000000..d7f0659 --- /dev/null +++ b/šola/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/šola/p1/dn/DN01_javniTesti/test01.in b/šola/p1/dn/DN01_javniTesti/test01.in new file mode 100644 index 0000000..9290688 --- /dev/null +++ b/šola/p1/dn/DN01_javniTesti/test01.in @@ -0,0 +1 @@ +4 6 diff --git a/šola/p1/dn/DN01_naivno.c b/šola/p1/dn/DN01_naivno.c new file mode 100644 index 0000000..ae6547c --- /dev/null +++ b/šola/p1/dn/DN01_naivno.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <stdlib.h> +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/šola/p1/dn/tj.sh b/šola/p1/dn/tj.sh new file mode 100755 index 0000000..b883d3e --- /dev/null +++ b/šola/p1/dn/tj.sh @@ -0,0 +1,27 @@ +#!/bin/bash +d=$3 +[ x$d = x ] && d=. +echo "$0 -- Anton Luka Šijanec <anton@sijanec.eu> -- 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 |