Общий форумHints for Java'ers who also hates problems like this and doesn't want to write automation-based solution. new BigDecimal(line1) - it's almost cool, but you need some fixes before use constructor 1. Check for empty fraction case, e.g. "1.", "1.e2", "1.E2" - these are NANs according P1074 grammar, but OK according BigDecimal grammar (this is the only difference in grammars). 2. Fix big exponent to something smaller, for BigDecimal to be able to parse it e.g. e1000000000000 => e1000 e-1000000000000 => e-1000 Edited by author 09.02.2013 06:24 can you show your answer? <input (replace 'S' with spaces!):> S 1 34 10 - 1 -. 1 -.e0 1 -.1e 1 #123 1 --123 1 -1.e6 1 S4 4 12345678e-100000000000000000000000000000 10 0.0e10000000000000000000000 1 # <output:> Not a floating point number 34.0000000000 Not a floating point number Not a floating point number Not a floating point number Not a floating point number Not a floating point number Not a floating point number Not a floating point number Not a floating point number 0.0000000000 0.0 <input> #S 1 S# 1 # <output> Not a floating point number Not a floating point number Thank you so much! very helpful I use segment tree to solve this problems(O(n^2logn)). And I have checked my program with an solution(already accepted) for many times. All my answer is correct. But still wa#2. Sorry for my poor English. Please help me,Thank you. After I have correct my code. I got wa#85 now!!! faint! Who can help me? For WA #2 one should make sure that the Segment Tree is initialized to -INF. Что нужно поправить,чтобы эта программа реализовывала тест '60 100 300 1'?вообще она ломается на 10 тесте при сдаче, но после того как я посмотрела обсуждения и прогнала её по найденным тестам поняла что не могу реализовать только один выше сказанный ответ кстати (как я думаю) 298. вот тесты на которых пробовала. к стати я очень невнимательная, поэтому сильно на меня не ругаться ))) 150 50 1000 100 ответ - 450 1 4 2 2 ответ - 2 1 3 5 2 ответ - 4 2 1 1 1 ответ - 2 1 3 4 3 ответ - 4 1000 2 2000 3 ответ - 140 11 1 10 2 ответ - 11 4 3 6 1 ответ - 6 1 2 12 3 ответ - 6 var a,b,c,d:integer; begin read(a,b,c,d); if a>c then write(a) else begin while a<>c do begin a:=a+b; if (a>c-d)and(c>a) then c:=a else if a+b>c then a:=c else if a=c then break else c:=c-d; end; write(c); end; end. Заранее спасибо)♥_♥ Edited by author 28.12.2017 21:55 Edited by author 28.12.2017 21:56 Let's take a look at this simple test: 32 36 80 4 The process goes like this: 32 -> 80 -> 32+36=68 -> 80-4=76 -> 68+36=104>76, so the end result is 76. Now, let's take a look at how you handle it. a=32 b=36 c=80 d=4 a:=a+b; -> a = 68 now if (a>c-d)and(c>a) then c:=a -> 68>80-4 is false, so this doesn't trigger else if a+b>c then a:=c -> 68+36=104>80, a becomes 80 here. then, while a<>c is checked again, a = c = 80 at this point, so it jumps to write(c). However, answer is 76 and not 80. Hope this helps you to figure out the problem! 150 50 1000 100 Why in this test answer is 450 (not 500) ? I had WA4 because of this: AnD <=> and, NOt <=> not, etc. I had WA9 because of this: empty strings (only spaces) - this is not a command)) I had TLE 13 because of this: we should ignore as a command lines has only a label) Cool problem)) Good Luck) Edited by author 07.04.2008 12:41 Well, now you don't have AC :) I can also add that you should do some pre calculations to get access to the variables' values and labels' positions with constant time. Logarithmic complexity isn't enough to pass TL. >Well, now you don't have AC :) Test 14 was added by me recently, which is why~ The only hint i can give for it is that the code prevented TL #13, but did it in not exactly a proper way. Took some time to rewrite that crap and retake AC :) Still don't know what was wrong in TL 14 of the previous solution though. #include <iostream> #include <math.h> #include <iomanip> using namespace std; int main(int argc, char const *argv[]) { long number; double sqrts[256]; int k = 0; while ( cin >> number ) { sqrts[k] = sqrt(number); k++; } for ( int n = k - 1; n > -1; n-- ) { cout << fixed << setprecision(4) << sqrts[n] << endl; } return 0; } Edited by author 29.11.2018 20:32 http://acm.timus.ru/help.aspx?topic=cpp C and C++ programs are compiled on the server with the 32-bit Microsoft Visual C++ 2017 or MinGW GCC 7.1 or Clang 4.0.1. So sizeof(long)==4. You should run locally/debug programs using 32 bit compiler too. Btw, why do you think 256 sqrts is enough? How did you estimate it? скорее всего ошибка с функцией Eof() ибо впервые ей пользуюсь и смутно представлю принцип работы. Если её нельзя использовать, то как найти конец вводимого файла? var s,sk:string; var i,fl,j,code:integer; var n:real; var a:array [1 ..256] of real; var f:array [1 ..256] of integer; begin while (Eof()<>True ) do begin readln(s); for i:=1 to length(s) do begin if (s[i]<>' ') and (fl=0) then begin fl:=1; sk:=sk+s[i]; end else if (s[i]<>' ') and (fl=1) then sk:=sk+s[i];
if (((s[i]=' ') and (fl=1)))or ((i=length(s))and(fl=1)) then begin fl:=0; val(sk,n,code); for j:=1 to 256 do if f[j]<>1 then begin a[j]:=sqrt(n); f[j]:=1; sk:=''; n:=0; break; end;
end; end;end; for i:=1 to 256 do if (f[i]=1) then writeln(a[i]:0:4); end. Did anyone else got this before me? Let's try to find what's type of test it is.. first I tried this problem with 1-0 bfs, but it was giving me wa5. when I coded it int dijkstra with edges of 0,1,2,3, I got AC. so is minimal k necessary? import random letters = ['a' ,'b' ,'c' ,'d' ,'e' ,'f' ,'g' ,'h' ,'i' ,'j' ,'k' ,'l' ,'m' ,'n' ,'o' ,'p' ,'q' ,'r' ,'s' ,'t' ,'u' ,'v' ,'w' ,'x' ,'y' ,'z'] example = 'xitsa' while len(example) < 199999: letter = random.choice(letters) point = random.randrange(0, len(example)) example = example[:point] + letter + letter + example[point:] print(example) А вот эта фраза "Пока господин Чичиков играл, ревизор несколько раз подходил к столу и забирал из лузы последний закатившийся туда шар" может быть понята двояко. Либо буквально "последний закатившийся", и тогда после изъятия последнего закатившегося шара нельзя брать ещё, пока не появится следующий последний закатившийся (то есть до следующего забитого шара: потому что последний уже взят, и следующий шар в лузе - предпоследний закатившийся), либо имеется в виду просто верхний, который может быть последним из оставшихся неизъятыми, а не буквально "последним закатившимся". Так что же имеется в виду авторами задачи и, главное, тестов к ней ? Это важно, потому что я читал эту фразу буквально, а при таком прочтении обязательное условие относительно шаров, изъятых до конца игры - то, что они должны идти по возрастанию. В случае второго варианта этого условия нет. Я-то привык всегда понимать задание буквально, считая, что авторы задания чётко понимают смысл своих слов. Wrong answer on test 4: #include<iostream> using namespace std; //Разложение на простые множители числа n unsigned long long int PrimeFactorization(unsigned long long n) { unsigned long long int k(0); unsigned long long int m = (int)sqrt(n) + 1; for (int i(2); i <= m; i++) { if (n%i == 0) { while (n%i == 0) { n /= i; k++; } } if (n > 1 && i == m - 1) { k++; } } return k; } int main() { setlocale(LC_ALL, "rus"); unsigned long long int a, b; int n; cin >> n; unsigned long long int* ans = new unsigned long long int[n]; for (int i(0); i < n; i++) { cin >> a >> b; if ((b%a) == 0) { ans[i] = PrimeFactorization(b/a) + 1; } else ans[i] = 0; }
for (int i(0); i < n; i++) { cout << ans[i] << endl; } if (n == 0) cout << 0; return 0; } I think my program is right , but I get WA . program Ural_1150; // Digits const bit:array[1..10] of longint= (1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000); var num:array[0..9] of longint; n,i,j,x:longint; begin readln(n); for i:=1 to 9 do begin x:=n mod bit[i+1] div bit[i]; for j:=1 to 9 do begin num[j]:=num[j]+n div bit[i+1]*bit[i]; if x>j then num[j]:=num[j]+bit[i] else if x=j then num[j]:=num[j]+n mod bit[i]+1; end; if n>=bit[i+1] then begin num[0]:=num[0]+n div bit[i+1]*bit[i]-bit[i]; if x>0 then num[0]:=num[0]+bit[i] else num[0]:=num[0]+n mod bit[i]+1; end; end; for i:=0 to 9 do writeln(num[i]); end. My O(N * log N + M) solutions gets TL What I'm doing wrong? Have somebody any tests? please! I am not able to understand the problem fully. In the first test why 221 or 122 are not included. But 212 is included. If somebody got this problem, please explain In the example, good albom can't contain two 2 together, because 2 > b = 1. I have true answers on all tests with this forum, but have WA#9! Help me! This is my code: #include <iostream> using namespace std; int main() { char str[201]; int c = 0; int cmax = 0; int index = 0; const char S[7] = {'S','a','n','d','r','o','\n'}; gets(str); for(int i=0;i<strlen(str)-5;i++) { if(str[i]=='S') c+=2; if(str[i]=='s') c++; if(str[i+1]=='a') c+=2; if(str[i+1]=='A') c++; if(str[i+2]=='n') c+=2; if(str[i+2]=='N') c++; if(str[i+3]=='d') c+=2; if(str[i+3]=='D') c++; if(str[i+4]=='r') c+=2; if(str[i+4]=='R') c++; if(str[i+5]=='o') c+=2; if(str[i+5]=='O') c++; if(c>cmax) { cmax = c; index = i; } } c = 0; if((str[index]=='s')||((int(str[index])<=90)&&(str[index]!='S'))) c++; else if(str[index]!='S') c+=2;
if((str[index+1]=='A')||((int(str[index+1])>90)&&(str[index+1]!='a'))) c++; else if(str[index+1]!='a') c+=2;
if((str[index+2]=='N')||((int(str[index+2])>90)&&(str[index+2]!='n'))) c++; else if(str[index+2]!='n') c+=2;
if((str[index+3]=='D')||((int(str[index+3])>90)&&(str[index+3]!='d'))) c++; else if(str[index+3]!='d') c+=2;
if((str[index+4]=='R')||((int(str[index+4])>90)&&(str[index+4]!='r'))) c++; else if(str[index+4]!='r') c+=2;
if((str[index+5]=='O')||((int(str[index+5])>90)&&(str[index+5]!='o'))) c++; else if(str[index+5]!='o') c+=2; cout<<c*5<<endl; return 0; } Try the test: sssssssssssssssssssssssssssssssssssssssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnnnnnnnnnnnnnndroooooooooooooo Your program's answer is 30. The right answer is 15. ( 1.sssssssssssssssssssssssssssssssssssssssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnnnnnnnnnnnsnndroooooooooooooo 2.sssssssssssssssssssssssssssssssssssssssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnnnnnnnnnnnsandroooooooooooooo 3.sssssssssssssssssssssssssssssssssssssssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnnnnnnnnnnnSandroooooooooooooo ) The wierd thing is that for "mmndro" the answer is right. :D I got the bug. In the first for, your c is always increasing, so your cmax will be wrong. Put "c=0" before to close the for. It should work perfect now. 1) кучи должны быть одинаковыми? 2) если нет то почему нельзя взять самое маленькое число и вычесть из него остальные? There are a number of wonderful languages supported already, but it would be great if Common Lisp were added as well. Have there been any plans to do so? SBCL is the most popular -- and one of the oldest and still very actively maintained -- open source implementations of Common Lisp, and it is very, very, fast[0]. Could SBCL please be added to the list of supported languages? It would be really appreciated. [0]: https://github.com/sbcl/sbcl Edited by author 24.11.2018 09:46 |
|