Общий форумthe programme just keeps taking input. how to make it stop taking input and print result You can get the whole input data as a big string with stdin.read() [don't forget to import stdin from the sys module]. It works on my computer, but judgement result is Wrong Answer. #include <stdio.h> #include <math.h> #define MAXSIZE 65536 int main() { unsigned long int value = 0; int counter = -1; int i = 0; unsigned long int a[MAXSIZE]; while (scanf("%lu", &value) != EOF) { a[++counter] = value; } for (i = counter; i > -1; i--) { printf("%.4f\n", sqrt((double)a[i])); } return 0; } Edited by author 21.04.2013 19:50 be confirmed that input limit is covered by your program Try to use unsigned long long, because 10^18>2^32 the array is too small,you can try global array to solve it ,but it should be large,at least 500000 It should be noted that problem statement doesn`t say that strings with numbers of friends for each friend is ordered - order of numbers can be random. And if algorithm wrong writed, it will be make problem (I have WA on test 9 many times, before i understood this) Here is my code. Give me some example to test: def sumnum(n): n=str(n) a=0 for i in n: a+=int(i) return a a=int(input()) num=[a+1,a-1] l=1 b='' c='' for a in num: a=(str(a)) b=a[:len((a))//2] c=a[len((a))//2:]
b=sumnum(b) c=sumnum(c) if b==c: print ('Yes') l=0 break if l: print ('No') Hi, I have read all messages from the forum about this test 14, but nothing helps. Here is my code [code deleted] , what is wrong? Thanks in advance/ Edited by moderator 06.12.2019 20:41 Just instead of "if(res2>res1)" "if(res2>=res1)" Hi, At first my program finds the flights that lead to smallest time, and get WA13. Then I modified one line: trace(target, bestTime); to trace(target, timeInInput); and got accepted. I already added edges from (u,t) --> (u,t') for t' > t, so that if my bfs finds a path to (u,t), it should also find a path to (u,t') for all t' >= t. So I think either judge is incorrect, or test data is weak (such that my wrong code got accepted). Hi, I encountered the same result (WA @ 13) as you did, and after a second thought, I realized that we had misunderstood the problem statement, in which an important sentence shall be noted: "Since such a meeting would likely be fatal, it cannot be allowed until the job is done." Remember that you need to wait for the rebel leader to appear at TIME_IN_INPUT. Therefore, if you take another round-trip to arrive at sometime earlier than first arrival, you would definitely meet yourself, which would be fatal. That's why we need to terminate the program once we arrive at the destination earlier than TIME_IN_INPUT. BTW, it SEEMS that terminating the BFS process in such a way would lead to the smallest k. Could anyone explain the difference between using scanf("%c", &ar) and scanf("%c", &ar, 1)? (when I use the first, I get WA #1, when the second, I get AC) Why is this happen and what does that third argument mean? Thanks for the answers. using System; namespace console_aplication54 { internal class Program { private static void Main(string[] args) { string[] nm = Console.ReadLine().Split(' '); if (int.Parse(nm[0]) >= 1 && int.Parse(nm[1]) <= 1000) { double x,y; x = double.Parse(nm[0]); y = double.Parse(nm[1]); Console.Write(Convert.ToInt32(Math.Ceiling(x*2)/y)); } } } } "It is known that no workman gets more than 10^9 rubles." Can't anyone of them gets more than 10^9 or it's only guarantee of existense solution with no more 10^9? If solution with no more than 10^9 rubles, output it. Else find the first record, after which salary with more than 10^9 rubles appears (or contradiction between salaries). I use binary search to find the answer. My algo to check answer: 1) Sort every edge by first man (we get two edges from every record) 2) Use dfs to find dependend groups. 3) First, make all salaries 0. 4) Get mens' salaries by going one by one in array of edges. Here we can find a contradiction between salaries. 5) In Vasiliy's group check all salaries on <0 or >10^9. 6) In other group find the minimum and the maximum salaries and if max-min>10^9 then it's wrong record. Else every salary=salary-min to make all salaries in [0..10^9]. It seems correct, but my program in Java get WA 8 and ONE Pascal program get WA 1, WA 8 and WA 16 O_o How do you search the answer? Separately for every dependent group? And what is the answer (you get salaries in 4 point so answer isn't salaries)? Answer is the number of last possible record. If Answer<m I output "Impossible ..." else I write the mens' salaries. No. I form every dependent group every time in binary search, becouse some record are unavailable for this. I form dependent group only for check answer. Thank you for your help becouse I have no idea... Algorithm seems to be correct. I think mistake in program. Thank you very much. I will try to find a mistake. I found error. I must sort edges by bfs, not simple sort. Edited by author 16.01.2011 13:22 Thanks to authors And what's cool here? IMHO, quite standard DP. Don't understand, why so few authors have solved it... It was cool in finding proper layout (for me at least). Of course, counting routes was trivial. Problem is very difficult. I think that answer is maximal cycles degree of vertices, or maxilal number of cycles containing some vertex. All Right but max lengs of cycles must be used also. Test: 14 91 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 7 8 7 9 7 10 7 11 7 12 7 13 7 14 8 9 8 10 8 11 8 12 8 13 8 14 9 10 9 11 9 12 9 13 9 14 10 11 10 12 10 13 10 14 11 12 11 13 11 14 12 13 12 14 13 14 Answ: 8463398736 Indeed, very cool problem when trying to prove it. I can't imagine what can it be couse i tried all tests from another topic and also mine but all of my and other's tests it solves, but test #3 Could you help me? By binary search and submitting find this test =) Test 3 is 1 5 2 8 3 10 4 9 5 5 answer is 2 i Edited by author 08.05.2013 14:56 My program gives the following answers: 1 -> 10 2 -> 45 3 -> 165 10 -> 43749 40 -> 45433800 80 -> 9 81 -> 1 Why do I get WA1? Edited by author 13.07.2012 14:17 Your solution is correct for every case. But whats your answer for 0? I think it should be 1. But its not testing case 0. Edited by author 06.05.2013 19:19 Edited by author 06.05.2013 19:19 Edited by author 06.05.2013 19:21 #include <stdio.h> #include <stdlib.h> #include <math.h> int main() { static int j; double *a; long long i; a=calloc(0,sizeof(double)*268435456); while(scanf("%lld", &i)!=EOF){ a[j]=sqrt((double)i); j++; } for(;j;j--,printf("%.4f\n",a[j])); } My solution passed all tests what I could think of. But I got WA on test #2. What's wrong? Give me some tests, please. Edited by author 14.11.2012 16:53 First 3 elements are answer there. Check default answer if nothing better than beggining is given 3 1 800 800 0:00 1 1439 1439 23:59 Answer: 4317 2 1 1439 1439 1:00 Answer: 2938 2 1 1439 1439 0:00 Answer: 2878 3 1 1439 1439 23:59 1 1439 1439 0:00 Answer: 5758 3 1 0 0 2:00 1 0 0 2:00 Answer: 120 |
|