Edited by moderator 23.08.2020 01:17 Will your program compose digits for primes {2,2,2,3} correctly? Looks like it will build 46, but answer should be 38. P.S. https://ideone.com/s0bjlI - really 46. Edited by author 29.09.2016 14:06can anyone please tell me what is test case 2 I don't know what my code's problem is. I have tested all input and got correct output, however I got WA#1 when summitting. Please help me!! Edited by moderator 23.08.2020 01:19 My code is ok all tests before #8, but I've WA on #8... Anything that I don't see? Thanks Can anyone help me? I have the same problem and I know the code is ok, I checked it 100 times Edited by author 29.07.2005 01:06 I also had WA on test#8(now I have AC). I don't know this test, but look: N = 362880 Right Q is 2578899. You see: all numbers(digits)in Q must be sorted: 2<=5<=7<=8<=8<=9<=9 - it's condition for minimal Q, but you must surch begining from 9
in my program the digits are sorted. for your example my answer is also 2578899 correct answer for 0 is 10. maybe this fact help you. my God..my alog is WRONG. thx! Edited by author 02.10.2011 20:48 May be this helps. If input is 12 output should be 26 not 34 . It is something strange... My program outputs 10, when input is 0, in your examples: 12 -> 26, not 34, but I have WA#8, why????? Program is correct, maybe tests are wrong??? Yes i am having the exact same problem... considered all test cases and am getting the write answers in ascending order but test#8 is giving WA Edited by author 03.12.2005 18:23 Edited by author 03.12.2005 18:23 I think tests are OK. If you still need some help send me your code to sk1@hotbox.ru try input 1000 000 000 I have this problem too!!! All test, what i see is correct; I use unsigned long; May be it consist false; What I doing wrong? Edited by author 05.04.2006 14:23 How about N = 13 ? ;) test Edited by author 04.07.2006 19:44 my solution in c++ 0.031 s. #include<iostream> #include<cmath> #include<string> #include<algorithm> using namespace std; inline bool isprime(long a) { if(a==1)return false; if(a==2)return true; if(a%2==0)return false; for(int i=3;i<sqrt(a);i+=2) { if(a%i==0)return false; } return true; } int main() { string a; long n; int d=1; cin>>n; if(n==0)cout<<"10"<<endl; else if(n==1)cout<<"1"<<endl; else{ if(isprime(n) && n>10)d=0; else { int gamyop=9; while(n!=1) { if(n%gamyop==0) { a+=(gamyop+'0'); n/=gamyop; if(isprime(n) && n>10){d=0;break;} } else { gamyop--; } } } sort(a.begin(),a.end()); if(d==1)cout<<a<<endl; else cout<<"-1"<<endl; } return 0; } I have this problem too!!! All test, what i see is correct; I use unsigned long; May be it consist false; What I doing wrong? Edited by author 05.04.2006 14:23 try string,or int64 try string,or int64 if I using __int64 I have overflow too. In this problem must use only string for result. I used recursive algorithm. (C++) result and local variables in function must be __int64(long long) In other cases you'll get an overflow Usage of string not are obligatory Test#8 is: N=1 000 000 000 Q->555555555888 for examle with local or result variables of type unsigned you'll get Q->1504774704 Sorry for my English :) I don't know if what is exactlly the test but the answer is something like -1 or 26 ;D It works for me there after fixing that... ;) Yep... problem in java was using int instead of long. Yep... problem in java was using int instead of long. I have Q->555555555888 when N=1 000 000 000, but Test#8 say "WA". Why? thanks mate. I was getting wrong for this reason. Those who are getting WA at Test #8. try to use "Unsigned long long int" insted of "int". So, i wrote my program for a warn-up to commercial programming, but i have a problem at this problem. It gives me wrong answer at the first test and i need your help, guys from this site. Here's the code: // Percentofpeople.cpp : Defines the entry point for the console application. // // Your task is to find the minimal positive integer number Q so that the product of digits of Q is exactly equal to N. #include <iostream> #include <string> int main() { int number; // a number that we need to get std::string answer; std::cout << "Enter the number: " << std::endl; std::cin >> number; for (int i = 9; i >= 2; i--) { while (number > 1 && number % i == 0) // if we can divide number and before it gets to 1 we'll do the following code: { answer = std::to_string(i) + answer; // add the number that divides N completely number /= i; // divide } } if (number == 1) std::cout << answer; else std::cout << -1; std::cin.get(); std::cin.get(); return 0; } I dunno how it looks but i think you'll understand it. So, where is the problem? The problem is with numbers from 1 to 9 or what? First of all, you should remove or comment out this row std::cout << "Enter the number: " << std::endl; The robot doesn't know what this text is supposed to mean, it expects only a numerical answer in the output. After this, you should be getting WA3. if is_test_script: print True if begin_script(10) == 25 else False print True if begin_script(9) == 9 else False print True if begin_script(150) == 556 else False print True if begin_script(11) == -1 else False print True if begin_script(10000000000) == -1 else False print True if begin_script(1000000000) == 555555555888 else False print True if begin_script(167) == -1 else False print True if begin_script(24) == 38 else False print True if begin_script(180) == 566 else False print True if begin_script(360) == 589 else False print True if begin_script(0) == 10 else False print True if begin_script('test') == -1 else False print True if begin_script(1013) == -1 else False print True if begin_script(27) == 39 else False print True if begin_script(1) == 1 else False print True if begin_script(0001) == 1 else False print True if begin_script(45) == 59 else False print True if begin_script(40) == 58 else False print True if begin_script(22) == -1 else False that tests are true Edited by author 29.05.2016 05:08 Edited by author 29.05.2016 05:09 What is Test #3? Having the same question As I had included this condition, I've past the third test: if (a == 1 || a == 2 || a == 3 || a == 7 || a == 5) Console.Write(a); Test #3 is n = 1 so you must return 1 If someone is interested Test# 4 is the following Q=0; Output = 10; Ruben Alanakyan, Thank You! Thanks, man! But this test looks little bit artificial, if you know what I mean... ;) Edited by author 07.11.2008 20:08 Why the output is 10? "the minimal positive integer number Q" Q must not be greater than 0 Isn't "Q must be greater than 0" ???? thx man, It caused many failings Thank you very much! Thanks! Edited by author 26.06.2013 02:46 Doesn't make any sense but anyway, thanks a lot. Thank you so much. I leant a lot! I need to read more carefully! thank you very much !!!!!!!!!!! Спасибо! Если бы ты не сказал, я бы так и не смог сделать! Еще раз огромное спасибо! Ruben, thank you very much! lol this is "creul and unusual punishmnt" Program must return Q=10 if N==0 and Q=1 if N==1. This is not what one should expect from the description of the problem. what should it return for N = 5? Is Q 5 or 15 then? Thanks Your task is to find the MINIMAL positive integer number Q... If n=5 you must print 5, no 15. Edited by moderator 23.08.2020 01:25 For example I'm going to enter "40". Your program shows "2225", though should have been seen something like "58". If I understood the clause right. (source removed after AC) Edited by author 23.01.2015 06:01 Resolved issue. Hints for those who look at this for reference. While this may not be the most elegant solution, it works. Make sure that: - Large values work. Try to imagine how many digits your solution could be composed of... - Values that may result in a legal (0-9) divisor at first, followed by a prime number... - As stated before, 0 and 1. Remember it's the LEAST positive integer... Edited by author 23.01.2015 06:00 New tests have been added. All accepted solutions have been rejudged. 886 authors have lost AC. such a fool i was 5 years ago... and test is so simple :) I am getting WA in test#10. Can anyone help me??? Thanks in advance. :) can you help me? fail is on fifth test... mikael@ubuntu:~/Desktop$ ./xx 1 1 mikael@ubuntu:~/Desktop$ ./xx 0 10 mikael@ubuntu:~/Desktop$ ./xx 2 2 mikael@ubuntu:~/Desktop$ ./xx 3 3 mikael@ubuntu:~/Desktop$ ./xx 4 22 mikael@ubuntu:~/Desktop$ ./xx 5 5 mikael@ubuntu:~/Desktop$ ./xx 6 23 mikael@ubuntu:~/Desktop$ ./xx 8 24 mikael@ubuntu:~/Desktop$ ./xx 9 33 mikael@ubuntu:~/Desktop$ ./xx 10 25 mikael@ubuntu:~/Desktop$ ./xx 20 45 mikael@ubuntu:~/Desktop$ ./xx 25 55 mikael@ubuntu:~/Desktop$ ./xx 30 56 mikael@ubuntu:~/Desktop$ ./xx 45 59 mikael@ubuntu:~/Desktop$ ./xx 60 256 mikael@ubuntu:~/Desktop$ ./xx 105 357 mikael@ubuntu:~/Desktop$ ./xx 108 269 mikael@ubuntu:~/Desktop$ Mikael, according your outputs: 2->2, 3->3, and why is 4->22? Maybe 4->4 is right answer? Обратите внимание на результат при N = 1000000000. А точнее на его размер 555555555888 в 32 бита он не поместится. 8 тест из-за этого выдает "Wrong answer". tell me, please, what input in test 5. use long long int instead of int , it may help.. if N=1 000 000 000 i have Q->555555555888. And as i read it's right answer. Edited by author 06.01.2013 05:07 N=12 Q=26 not 34. 34 or 26 But 26 is less than 34 Edited by author 24.11.2012 23:51 To whom it may concern! There were sovlved two different programms. The first one, when there is given an input 120 the output is 358; the second output is 456. But both of them were accepted. Could you explain to me why this that, if you please? It's because of weak tests :D var a:array[1..10000] of Longint; b:array[1..10000] of string; min,c,n,i,j,k:Longint; s:string; begin read(n); for i:=2 to n-1 do begin if n mod i=0 then j:=i; if (j<>0) and (j<10) then begin k:=k+1; str(j,b[k]); str(trunc(n div j),s); b[k]:=b[k]+s end; end; for i:=1 to k do val(b[i],a[i],c); min:=a[1]; for i:=1 to k do if min>a[i] then min:=a[i]; if min<>0 then write(min); if j=0 then write('-1'); end. |
|