Common Boardfirst 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. 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:46u have 3 arrays, so. try to compare arr1 and arr2 and if u found matched numbers, then compare the second and the third arrays, if u got matched again - count var +1 in the end just writeline (count) Edited by author 23.11.2018 18:22 #include <iostream> #include <iomanip> #include <math.h> using namespace std; int main(){ unsigned long long input; double array[4]; int dem = 0; while (dem < 4 && cin >> input ){ array[dem] = sqrt(input); dem++; } for ( int i = dem - 1; i >= 0; i--) cout << setprecision(4) << fixed << array[i] << endl; } there should not have a array that with 4 length, it may have 5 or 6 or 100...echo, there is no limit why wa#17? help pls Edited by author 23.11.2018 08:05 Can anyone please tell me what's in test 19? please? Btw I just checked the LCMs of all numbers from 1 to 31607 using OEIS and they matched, soI have no idea where the error is. For two days I can not solve this problem, tell me, please, what is test number 4? I am trying to solve this problem by using the same approach that I used yesterday to solve this http://acm.timus.ru/problem.aspx?space=1&num=1009 problem. Is my approach correct? Someone give me a little hint , please..... I am stuck here Edited by author 22.11.2018 18:12This problem can be solved in logarithmic time by using of such formula |F_{n+1} F_n| |k-1 1|^n |k-1 1| | | =| | x | | |F_n F_{n-1}| |k-1 0| |1 0| and applying fast multiplication. The answer is F_n. This formula generalize corresponding formula for Fibonacci sequence https://www.nayuki.io/page/fast-fibonacci-algorithms. It can be easily proven by induction. but the formula is wrong when n=2 Edited by author 21.11.2018 23:38 Edited by author 21.11.2018 23:38 I love Javascript, please could you add Javascript (NodeJS) so it will makes problem solving easier (with less coding) Thanks! I am not able to understand the problem properly. Is there somebody who can explain the problem with example. Pls Edited by author 21.11.2018 16:56 Edited by author 21.11.2018 16:57 |
|