ffprog:ffprogjava2016:inputoutput

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ffprog:ffprogjava2016:inputoutput [2016/09/09 20:49]
Ivo Blöchliger [SOI - Aufgaben]
ffprog:ffprogjava2016:inputoutput [2016/09/11 21:05] (current)
Ivo Blöchliger [SOI - Aufgaben]
Line 107: Line 107:
   * Input: {{ :ffprog:ffprogjava2016:simple.txt |simple.txt}}. Korrekter Output: {{ :ffprog:ffprogjava2016:simple-lsg.txt |simple-lsg.txt}}   * Input: {{ :ffprog:ffprogjava2016:simple.txt |simple.txt}}. Korrekter Output: {{ :ffprog:ffprogjava2016:simple-lsg.txt |simple-lsg.txt}}
  
-==== SOI - Aufgaben ==== 
-  * z.B. https://soi.ch/contests/2016/round1/cablecar/ 
-  * Cable-Car Instanzen und Lösungen. Aufgabe 1 {{ :ffprog:ffprogjava2016:cable-10-100.txt |}} {{ :ffprog:ffprogjava2016:cable-10-100-output.txt |}} {{ :ffprog:ffprogjava2016:cable-50-10000.txt |}} {{ :ffprog:ffprogjava2016:cable-50-10000-output.txt |}} {{ :ffprog:ffprogjava2016:cable-100-1000000.txt |}} {{ :ffprog:ffprogjava2016:cable-100-1000000-output.txt |}} 
-  * Cable-Car Aufgabe 2: {{ :ffprog:ffprogjava2016:cable2-100-1000-1000000.txt |}} {{ :ffprog:ffprogjava2016:cable2-100-1000-1000000-output.txt |}} 
  
-=== Lösungsvorschlag Cablecar Aufgaben 1 und 2 === 
-<code java> 
-        Path datei = Paths.get("cable2-100-1000-1000000.txt"); 
-        // Speicher für die Ausgabe 
-        ArrayList<String> lines = new ArrayList<>(); 
-        try (Scanner scanner = new Scanner(Files.newInputStream(datei))) { 
-            int n = scanner.nextInt(); 
-            for (int i=0; i<n; i++) { 
-                int m = scanner.nextInt(); 
-                boolean ok = true; 
-                int a = scanner.nextInt(); 
-                int b = scanner.nextInt(); 
-                int d = b-a; // Differenz zwischen Masten 0 und 1 
-                for (int j=2; j<m; j++) { 
-                    int c = scanner.nextInt(); 
-                    if (c-b!=d) { // Mit letztem Masten vergleichen 
-                        ok = false; 
-                    } 
-                    b = c;  // Aktueller Mast wird letzter Mast 
-                } 
-                lines.add(String.format("Case #%d: %s", i+1, ok ? "yes" : "no")); 
-            } 
-        } 
-        // Einzeiler, das eine Liste von Strings in eine Datei schreibt. 
-        Files.write(Paths.get("output.txt"), lines); 
-</code> 
  • ffprog/ffprogjava2016/inputoutput.1473446952.txt.gz
  • Last modified: 2016/09/09 20:49
  • by Ivo Blöchliger