Common BoardShow all threads Hide all threads Show all messages Hide all messages | To Admins: Weak tests | Sirko | 1123. Salary | 1 Oct 2013 03:37 | 2 | I've got AC with program that returns 2552 for input 2433. Edited by author 28.09.2013 04:09 Edited by author 28.09.2013 04:09 Your test was added. Thank you. | Тест №6 (1001) | GaryFreeman | 1001. Reverse Root | 30 Sep 2013 15:39 | 3 | Всем привет! Помогите плиз, никак не могу пройти тест номер 6. Какие числа не подбираю, у меня все работает. А вот что-то там хитрое в этом тесте, если не составит труда, помогите. Вот код: [cpp] #include <cmath> #include <cstdio> int main(int argc, char* argv[]) { double tmp[32]; char i = 0; while (i < 32 && std::scanf("%lf", &tmp[i]) != EOF) { ++i; } for (--i; i >= 0; --i) { std::printf("%.4lf\n", sqrt(tmp[i])); } return 0; } [/cpp] You are probably joking =) Why did you decide that there can be at most 32 numbers in the input??? Wow, it's my mistake. Okey, so I can do working code, but tell my please, how does first place in top work? Only 760Kb of memory and 0.015s of working, it's amazing! My previus version was (0.421s/5244Kb) | Please, give some advices to solve this problem | ahmedov(NUUz_2) | 1593. Square Country. Version 2 | 30 Sep 2013 06:10 | 10 | 1) If N==a^2, that is if N is a full square, the answer is 1 2) Try N = a^2 + b^2. Brute force, but "clever" brute force. This is the most expensive part of the algo 3) N is NOT a sum of 3 squares <=> N=(8k+7)*4^m This is a fast step, about O(log(N)) 4) Lagrange theorem states: each number may be presented as a sum of 4 squares: N = a^2 + b^2 + c^2 + d^2 So if the upper three cases fails, the answer will be 4. Nice algorithm! Thank you, melkiy. But you can find N = a^2 + b^2 without brute-force. I considered this case by facrotizing N to primes and using Ferma-Euler theorem. How to apply Ferma-Euler theorem to this problem ? No brute force. Moreover, we don't need to find the sum of squares, we need just answer. find factorization of N = L*m^2, where L is not divisible by p^2 for p is prime. if L==1 then answer = 1 if L has no prime divisors of the form 4*t+3 then answer = 2 (Fermat) if N != (8*t+7)*4^k then answer = 3 (Legendre) else answer = 4 Got AC. Edited by author 22.01.2013 20:14 If L has prime divisors of the form 4*t+3,the answer may be 2,too. How to explain this question? Fermat's theorem says that if N=a^2+b^2, then L hasn't prime divisors of the form 4t+3, and back. A simpler to calculate approach is just to check if the prime decomposition contains no ODD powers of primes that can be expressed as 4*t+3, in which case the answer is two. | WA 24! | Ak@demik | 1534. Football in Gondor | 29 Sep 2013 17:04 | 1 | WA 24! Ak@demik 29 Sep 2013 17:04 Why WA 24? ... Give me some tests, please. | What is algo? | IgorKoval(from Pskov) | 1669. Universal Word | 29 Sep 2013 16:23 | 2 | simple DP: int leftPos[char][pos] position of char which is left or equal of pos int lastPos[mask] : for substring s[lastPos[mask]..s.length()-1] we can get all name of sportman with char which is in mask. =) | Please help. WA Test 6/ Помогите, пожалуйста. Неправильный ответ. Тест 6 | Alex | 1787. Turn for MEGA | 29 Sep 2013 15:41 | 2 | Не могу разобраться в чем ошибка. using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string[] s = Console.ReadLine().Split(' '); string[] d = Console.ReadLine().Split(' '); int x = 0; int n = int.Parse(s[0])*int.Parse(s[1]); for (int i = 0 ; i < int.Parse(s[1]) ; i++) { x = x + int.Parse(d[i]); } if (x > n) { x = x - n; } else x = 0; Console.WriteLine(x); } } } Вопрос снят. Ошибку нашел. | ac code | JDBaha | 1877. Bicycle Codes | 28 Sep 2013 23:10 | 6 | #include <iostream> int main() { int k1,k2; int count=0; int flag=1;
std::cin>>k1>>k2; for(;;) { if(flag==1) { if(count==k1) { std::cout<<"yes"; return 0; } count++; flag=-flag; } if(flag==-1) { if(count==k2) { std::cout<<"yes"; return 0; } count++; flag=-flag; } if(count>k1 && count>k2) { std::cout<<"no"; return 0; } }
} a better way: #include<iostream> using namespace std; int main(){ int lock1,lock2; cin>>lock1>>lock2; if(lock1%2==0||lock2%2==1){ cout<<"yes"; }else{ cout<<"no"; } return 0; } 1st. code is correct, but does not meet the requirements of the problem .. based on the conditions of the problem, such a check should be: if((a>0 && a <= 9999 && a%2 == 0)||(b>=0 && b <=9999 && b%2 ==1)) cout << "yes"; else cout << "no"; 0000 excluded from the search because the code has been entered., + indicated that a strictly four digit string to the test unchecked .. verdict .. flawed testing Edited by author 12.02.2013 17:11 #include <iostream> using namespace std; int main(){ int l,b; cin>>l>>b; l%2==0 || b%2==1 ? cout<<"yes" : cout<<"no"; } Edited by author 29.09.2013 13:22 Edited by author 29.09.2013 13:22 What's the meaning of your code ? and I'm not sure what's the main method to steal the bike by the thief. Could you mind tell me ? Edited by author 05.11.2012 22:48 you can see that thief is testing even code on night 1, 3, 5... and odd code on night 2, 4, 6... So thief can steal the bike if the code is even on night 1, 3, 5... and odd code on night 2, 4, 6... Code may be even on night 1,3,5 only if first lock have even code. Code may be odd on night 2,4,6 only if second lock have odd code. So you have to check only if first lock have even code or second have odd code. | Who solve this problem with DP, | ural_ghost | 1005. Stone Pile | 28 Sep 2013 19:10 | 8 | I have solved it with Dp in 0.015. Is there anyone fast(DP)? I'd be more interested in your memory strategy. I don't think DP alg will differ much for the same problem Maybe the test data are so simple, and DP is able to accept. But I don't think DP method is right. dp(bug task) and bruteforce (2^n) are both accepted for me it got accepted with brute force Time : 0.015 (I think its the minimal time) C++ using maps and vectors Used DP Want d code? gaston770@gmail.com Less than 15 lines of the algorithm My solution cost monstrously 0.187s using DP... Легко решается с динамическим програмированием. Делишь сумму камней на 2 части, потом запускаешь рюкзак до суммы камней/2, ответом будет являться abs(sum-2*maxx), где sum - сумма камней, а maxx - макс. вес, который мы можем поместить в наш "рюкзак" | test case #7 fail. please give it for me! | 1212314 | 1106. Two Teams | 28 Sep 2013 17:12 | 1 | test case #7 fail. please give it for me! | What is Test 8? | karan | 1183. Brackets Sequence | 28 Sep 2013 06:44 | 1 | Can anybody tell what is Test 8. Getting WA. | Wrong Answer | 1212346 | 1100. Final Standings | 27 Sep 2013 08:59 | 1 | #include <stdio.h> #include <iostream> using namespace std; #define MAX 15000 struct Team { int ID; int M; }; void Swap(Team &A, Team &B) { Team temp = A; A = B; B = temp; } void QuickSort(Team A[], int left, int right) { int i, j; if (left >= right) return; int x = ((left + right)/2); i = left; j = right; while(i < j) { while (A[x].M < A[i].M) i++; while (A[j].M < A[x].M) j--; if(i <= j) { Swap(A[i], A[j]); i++; j--; } } QuickSort(A, left, j); QuickSort(A, i, right); } void main() { int N; Team A[MAX]; cin >> N; for (int i = 0; i < N; i++) cin >> A[i].ID >> A[i].M; QuickSort(A, 0, N - 1); for (int i = 0; i < N; i++) cout << A[i].ID << " " << A[i].M << endl; } | Почему не правильно? | Kirill_M | 1009. K-based Numbers | 27 Sep 2013 01:46 | 2 | #include <iostream> #include <string> #include <stdio.h> #include <cmath> using namespace std; int n,k,col=0; int main() {
cin>>n>>k; int bo=0; int z,z1; z=pow(10.0,(n-1)); z1=pow(10.0,n); for(int i=z;i<z1;++i) { for (int v = i; v; v /= 10) { if (((v%10)>=k) || (((v%10)==0) && ((v%100)==0))) {bo=1; v=0;}; } if (!bo) ++col; bo=0; } cout<<col; return 0; } Насколько я понимаю, основание может быть отличным от 10, то есть с основанием, 2, 3, 4, 5, 6, 7, 8, 9. Из-за этого и запись разная, например число 31(осн. 10) = 11111(осн. 2) = 51(осн. 6) = 24(осн.8) = 1F(осн. 16). Вот такие пироги. | Is this looks like correct? | PVD | 1009. K-based Numbers | 27 Sep 2013 01:36 | 1 | i have tested it, and it look like working, can you say me is this look like correct, or can you advise me how to fix it?) #include <iostream> using namespace std; int main() { unsigned __int64 n, b, i, r, sum = 0; cin>>n>>b; for (i = 2; i <= n - 1; i++) { r = (n - 1) / i + (n - 1) % i; sum += r * pow(double(b - 1), double(n - i)); } cout<<unsigned __int64(pow(double(b), double(n)) - pow(double(b), double(n - 1)) - sum)<<endl; //system("pause"); } | Test 43 | Radostin Chonev | 1593. Square Country. Version 2 | 26 Sep 2013 20:31 | 1 | Test 43 Radostin Chonev 26 Sep 2013 20:31 Can anyone help me ? I have WA on test 43 . Thanks for your attention . | Compilation error | Evgeniy_Chernobrovkin(MUCTR-2013) | 1025. Democracy in Danger | 26 Sep 2013 03:01 | 1 | #include "stdafx.h" #include <iostream> #include <conio.h> using namespace std; void bubbleSort(int array[], int col){ int temp=0; for (int i=1; i<col ; i++){ for (int j=0; j<col-i; j++){ if (array [j]>array [j+1]){ temp=array[j]; array [j]=array [j+1]; array [j+1]=temp; } } } } int _tmain(int argc, _TCHAR* argv[]) { int k; int max; int sum; sum = 0; max = 0; cin >> k; int *p = new int[k-1]; int i; for (i = 0; i < k; i++) { cin >> p[i]; }
bubbleSort(p, k-1); k=k/2+1; for (i=0; i<k; i++) { sum = sum + p[i]/2+1; } cout << sum; _getch(); return 0; } kgxvh8-ov2fjo kgxvh8-ov2fjo(1) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory What's wrong? There is no problem in Visual Studio 12 :( | I use Dynamic Prog. May Be It's wrong. Help with test or hint, please. WA#3 | Alexey | 1156. Two Rounds | 25 Sep 2013 23:00 | 7 | My programm passes all my tests, but WA#3. Please, help. Thanks a lot. How you here have applied Dinamic Prog.? I the ambassador aside graph. Hi, Taras. I use simple method: I read two variables ot and ku. If ot and ku are in the same group, I Output('IMPOSSIBLE'); If they are in the different groups then I Continue else I put one variable into the first group and other into the second group. After that I divide "free" tasks between the groups... I hoped that It would get more than two tests... May be I should try to use graphs... BTW, tell me youre ICQ number, I cann't find you... Edited by author 02.05.2006 13:17 try this test, maybe will help you: 4 6 1 2 2 3 3 4 4 5 6 7 7 8 ANS: 1 3 5 7 2 4 6 8 You can use it. I used it as well. First you must paint the graph with black and white (use BFS) so that two vertices with the same edge are of different colors. After that you have pairs of integers and you have to combine them so that you have N in each round (that's not always possible). how I should combine them ?? | Wrong answer on test 2 !!!! | Narek X | 1809. Chapaev and Potatoes | 25 Sep 2013 18:26 | 1 | Thenks, I have AC Edited by author 27.09.2013 15:34 | WA 27? | jjohn | 1643. Attack of the Dark Fortress | 25 Sep 2013 13:25 | 1 | WA 27? jjohn 25 Sep 2013 13:25 I think my program is correct, but i've gotten wa 27 three times. Does anyone know what this test iss? | Why WA4 | KartonArmadon | 1581. Teamwork | 24 Sep 2013 18:16 | 1 | Why WA4 KartonArmadon 24 Sep 2013 18:16 Sorry please, i find mistake... Edited by author 24.09.2013 18:26 | Why WA on test 10? | Николай | 1880. Psych Up's Eigenvalues | 24 Sep 2013 17:47 | 1 | #include<iostream> #include<math.h> using namespace std; int main() {int t=0; int a,b,c; int d=0; long A[4001]; long B[4001]; long C[4001]; long D[4001]={0}; cin >> a; if(a <1 || a > 4000) exit(0); for(int i=0;i<a;i++) { cin >> A[i]; if(A[i] < 0 || A[i] >1000000000) exit(0); } cin >> b; if(b < 1 || b > 4000) exit(0); for(int i=0;i<b;i++) { cin >> B[i]; if(A[i] < 0 || B[i] >1000000000) exit(0); } cin >> c; if(c < 1 || c > 4000) exit(0); for(int i=0;i<c;i++) { cin >> C[i]; if(A[i] < 0 || C[i] >1000000000) exit(0); } for(int i=0;i<a;i++) for(int j=0;j<b;j++) if(A[i] == B[j]) { D[i]=A[i]; B[j]=0; t++; break; } for(int i=0;i<t;i++) for(int j=0;j<c;j++) if(D[i] == C[j]) { d++; C[j]=0; break; } cout << d; system("pause"); return 0; } |
|
|