|
|
Common BoardHello everyone, The problem description says that first you enter the phone number, then the number of words in the dictionary, then the dictionary itself, then -1. However, in the input example the first test looks like this: 7325189087 5 it your reality real our And then the second input begins. My question: why is there no -1 in the first example? -1 ends the whole input, ie. there will be no more phone numbers after -1. I too did not know what was wrong with my solution, but got accepted when replaced: for (int i = n; i >= 1; i--) if (time[i] < time[besti]) besti = i; with: for (int i = n; i >= 1; i--) if (time[i] + epsilon < time[besti]) besti = i; With epsilon = 1e-9. Good luck! :) Thank you very much. You really helped me: I did the same thing and got AC. for wa7 too work.. thx Edited by author 11.08.2014 17:44 always wa at test 11,why? I can't figure out what the hint about! Why “If the order of tests is “YES-NO-NO”, then Valentine's solution won't pass the second test only; if the order is “NO-YES-NO”, then it will pass none of the tests; if the order is “NO-NO-YES”, the solution won't pass the first and the third tests.” Can you give me more detailed explanation? This is test #11: 5000 12500 Who have answer? Edited by author 06.09.2013 20:53 The answer for that is 2500.50 Edited by author 10.08.2014 12:35 Edited by author 10.08.2014 12:35 why i always got wrong 3 ? me help this test: 4 0 1 0 2 0 3 0 4 right ans is: 1 1 1 1 Because you Ben!___Don't mind!I ever got WA for many times.- - Edited by author 03.10.2013 14:18 You can solve that with algo Djikstra. We have 6!*8*8 vertex (hash of cube and point) . And all vertexs have <=4 edges. P.s. sry for English ) Edited by author 09.08.2014 16:51 import java.util.List; import java.util.ArrayList; import java.util.Scanner; public class Spion { public static void main(String[] args) { Scanner in = new Scanner(System.in); List<String>shifr = new ArrayList(); String word = in.next();
shifr.add(""+word.charAt(0));
for(int i =1;i<word.length();i++){ String s =""+word.charAt(i); shifr.add(s);
if(shifr.get(shifr.lastIndexOf(s)).equals(shifr.get(shifr.indexOf(s))) && shifr.lastIndexOf(s)==shifr.indexOf(s)+1) { shifr.remove(shifr.get(shifr.lastIndexOf(s))); shifr.remove(shifr.get(shifr.indexOf(s)));
};
}
for(String n: shifr){
System.out.print(n); }
} } what's wrong? Can you please give me some tests? Тест №2 противоречит условию задачи , это тест такой : 1 1 0 (подобрал с помощью бинпоиска) import java.util.Scanner; public class AcmTimusRu { public static void main(String[] args) { Scanner s = new Scanner(System.in); int a = s.nextInt(); int b = s.nextInt(); if (39 + 2 * a > a + 2 * b) { System.out.println(2*a+39); } else { System.out.println(2*b+40); } } } Not a + 2 * b. You must use 40 + 2 * b. import java.text.DecimalFormat; import java.util.Scanner;
public class prob {
public static void main(String[] args) { Scanner c = new Scanner(System.in); DecimalFormat twoDecimals = new DecimalFormat("0.00%"); int n = c.nextInt(); int counter = 0; double m = c.nextInt(); int []a = new int [c.nextInt()]; for(int i = 0; i < a.length; i++){ a[i]= c.nextInt(); } for(int j = 1; j<=n; j++){ int z = j; for (int i = 0; i < a.length; i++){ if(a[i] == z) counter++; } System.out.println(counter*100 / m); } } } parsing in just one line XD from string import * from functools import * [[a1,b1],[a2,b2],[a3,b3]] = map(partial(map,int),map(split,map(raw_input, [""]*3))) & in py3k: from functools import * [[a1,b1],[a2,b2],[a3,b3]] = map(partial(map,int),map(lambda x:x.split(),map(input, [""]*3))) Edited by author 05.04.2014 04:37 a1, b1 = [int(num) for num in input().split()] a2, b2 = [int(num) for num in input().split()] a3, b3 = [int(num) for num in input().split()] print(a1 - a3, b1 - b2) I can't understand why my program work slow, I don't know any algorithm that can solvе this problem in beter time. My program solve it in 0.125s, when others in 0.031. Why ? Please help me :) :D моя ещё не знает, что я программно жарю котлеты :D |
|
|