Common BoardTry 8 4 2 4 4 6 6 8 8 2 Ans: 2 6 or 4 8 i have never met of this kind of matrix that is connecting with probablities.. I got WA#13 and I don't understand what's wrong in my program. I try tests from UNKNOWN_LAMER, and my program passed them. Please give me some interesting tests! 12 0 0 10 0 20 0 0 10 0 20 5 20 12 20 20 10 20 20 10 20 3 3 4 4 Answer: 1 Try this test: 2 1 0 2 0 P.S. Though N>2,this can appear in a little big test. why do you have to be cryptic! 12 0 0 10 0 20 0 0 10 0 20 5 20 12 20 20 10 20 20 10 20 3 3 4 4 Answer: 1 I don't know what happen with my code. I alway stuck at test#5. Could everybody give me some suggest? This is my code : #include<stdio.h> #include<stdlib.h> int main(){ int weight[20]; int stone_bag_num,i,temp,j,temp_group,group1,group2; scanf("%d",&stone_bag_num); /* printf("\nstone bag : %d\n",stone_bag_num); */ /* init weight */ for (i = 0 ; i < stone_bag_num;i++){ weight[i]=0; } /* input number */ for(i = 0 ; i < stone_bag_num ; i++){ scanf("%d",&weight[i]); /* printf("\nThe bag : %d weight : %d\n",i,weight[i]); */ } /* put the big weigth into bag 1 */ for (i = 0 ; i < stone_bag_num ; i++ ){ for (j= i+1 ; j < stone_bag_num ; j++ ){ if ( weight[i] < weight[j] ){ temp = weight[i]; weight[i] = weight[j]; weight[j] = temp; } } } /* printf("flag"); for (i = 0 ; i < stone_bag_num ; i++ ){ printf("The bag : %d weight : %d\n",i,weight[i]); } */ /* calcate the mid */ group1=0,group2=0; for (i = 0 ; i < stone_bag_num ; i++ ){ temp_group = ( ( group1+group2 ) /2 ); if( (group1 - temp_group) > (group2 - temp_group) ){ group2=group2+weight[i]; } else group1=group1+weight[i]; } /* printf("group1 : %d group2 : %d",group1,group2); */ if( (group1 - group2) > 0){ printf("%d",abs(group1 - group2) ); } else{ printf("%d",abs(group2 - group1) ); } exit(0); /*return 0;*/ } #include <iostream> #include <stdlib.h> #include <string> using namespace std; int main() { long length = 0; int answers_count = 0,over, result, total = 0; string str_; while(!(cin>>length) || length > 1000000000) cin.clear(); while(!(cin>>answers_count) || answers_count > 5000) cin.clear(); string **str = new string*[answers_count]; for(int i = 0; i < answers_count; i++) { str[i] = new string[3]; for(int j = 0; j < 3; j++) { cin>>str_; str[i][j] = str_; } } while(cin>>over && over != -1); for(int i = 0; i < answers_count; i++){ int first_pos = atoi(str[i][0].c_str()); int last_pos = atoi(str[i][1].c_str()); result = last_pos - first_pos; if((result+1)%2 == 0 && str[i][2] =="even" || (result+1) % 2!= 0 && str[i][2] =="odd") total++; } cout<<total<<endl; system("pause"); return 0; } sometime it's "wrong answer",sometime it's "complication error",who can analyse it detailed,thanks a lot! Edited by author 28.10.2009 16:46 For every point on the board, we change it into 24 different points in our graph. Every point means a state where the cube move onto it, eg (a,b) means "a" at bottom and "b" at front. Weights are the numbers on the bottom. Use dijkstra at last. Start dfs from starting node and when you crossed through some node more than 2 then return. I had WA #10 when i tried to solve this in second time. This test helped me to get AC; ((*Answer is YES*)) Thanks, this was very helpful! For example: Input 17 Output 2 9 80 Edited by author 29.06.2010 14:01 Yes. This answer is correct too. Any generating set with different positive integers strictly less than 10^5 will be OK. Input 17 Output 6 1 2 3 4 5 200 Yes. This one is correct too. #include <cstdlib> #include <iostream> using namespace std; int a[10000]; int main(int argc, char *argv[]) { int n, s, c , sum=0, y, i, l=1,x=0,ferq; cin >> n; for( i=1;i<=800;i++) {sum=0; y=i; while(y!=0) { c= y%10; sum = sum +c; y/=10; } a[l]=i; l++; x=x+sum;
if(x==n) {y=2;break;} else if(x>n) {l=l-1; x=x-sum;ferq = n-x; y=1;break;}
} if((ferq*100)>a[l-1]) cout << l<<endl; else cout << l-1<<endl; for(i=1;i<=l-2;i++) cout << a[i]<<" "; if(y==2) cout << a[l-1]; else { if((ferq*100)>a[l-1]) cout << a[l-1]<<" "<<ferq<<0<<0<<" "; else cout << a[l-1]<<ferq ; } system("PAUSE"); return EXIT_SUCCESS; } Yes I tried. 9999 779 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 8497 But maximal test is 10^5-1, not 10^4-1. :D It is unbeliavable. How I can't see it?. I am really very sorry. I've just got AC but with another solution. But I wonder, what is #12test? I tried: inp: 2 1 2 2 1 outp: 1 1 2 //------ inp: 0 outp: 0 PS I know, this test is incorrect. //------ inp: 4 1 4 2 8 3 6 5 7 outp: 2 1 4 5 7 First time I use list of segments. Algo: -find segment with max intersections -delete it from list And I do it while segment with max intersections have more then 0 intersections. Is it algo wrong? PS Sorry for my english. I used the same algo and got WA12. I think this test is: 5 3 6 7 8 1 2 0 4 5 9 Answer: 3 1 2 3 6 7 8 var m,i,n,n1:longint; function nod(a,b:longint):longint; {...} end; begin readln(n); n1:=(n-1) div 2; m:=0; for i:=1 to n1 do if nod(i,n)=1 then inc(m); writeln(m); end. i did the problem like u suggested:) and i got accepted but i dont really understand why is it like that..can u please explain me? Edited by author 18.02.2005 17:12 Edited by author 18.02.2005 17:12 // below I use divisibility by a real (not integer) number - hope that doesn't cause any confusions // Let us denote beta = Pi - alpha (from problem statement) You can easily prove that the process described in the problem statement means that we simply fix the initial point on a circle, and then jump around with angle beta. So now for given N you need to find the number of solutions for the following equalty: N * beta mod 2Pi = 0, such that N is minimal Obviously, beta must be p / N * Pi, where p is integer (elseway N * beta can't be divisible by 2Pi). But beta = Pi - alpha and 0 < alpha < Pi, so 0 < beta < Pi; this means that 0 <= p < N. On the other hand, p must be even - if it's not, N * beta = N * p / N * Pi = p * Pi will not be divisible by 2Pi. So p = 2 * i. So we have the following candidates for beta: 2 * i / N * Pi, where 0 <= i < N div 2 (because p < N). The last thing to take care of is that there's no such K < N that K * beta is divisible by 2Pi: K * 2 * i / N * Pi (not divisble by) 2Pi. This means that K * i must not be divisible by N for any K < N; which means that i and N must be coprimes. So the answer is number of coprimes of N that are smaller that N / 2. If A and N are coprimes, then (N-A) and N are coprimes too, so the answer is (number of coprimes of N that are smaller that N) / 2. To calculate this number we can use Euler's formula instead of a bruteforce solution: if N = a1^p1 * a2^p2 * .. * ak^pk, where all ai are different and all ai are primes, then number of coprimes smaller than N is E(N) = (a1 - 1) * .. * (ak - 1) * a1 ^ (p1 - 1) * .. * ak ^ (pk - 1) so the answer is E(N) / 2 Michael Rybak! Respect! int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } ans = 0; scanf("%d", &n); for (int i = 1; i <= n / 2; i++) { if (gcd(i, n) == 1) ans++; } This test helped me pass test #10! I hope it will help you too. 2 1 2 3 2 3 4 0 --- And answer 2 1 2 3 2 3 4. And just good test 5 1 5 2 6 7 3 8 9 3 11 15 3 17 20 4 4 6 8 4 9 10 4 12 14 2 17 19 2 --- And answer 5 1 5 2 8 9 3 11 12 3 14 15 3 19 20 4 GOOD LUCK! I think this test may be more useful: 1 1 10 -1 2 5 6 0 6 7 1 Answer: 2 1 5 -1 7 10 -1 Thank you ! I got wa in this test Here is test, that helped me to find problem in my code: 1 -10 10 26 3 -13 0 4 0 7 7 7 13 1 Answer: 0 Edited by author 18.10.2009 21:49 Edited by author 18.10.2009 21:49 This test helped me pass test #10! I hope it will help you too. 2 1 2 3 2 3 4 0 --- And answer 2 1 2 3 2 3 4. And just good test 5 1 5 2 6 7 3 8 9 3 11 15 3 17 20 4 4 6 8 4 9 10 4 12 14 2 17 19 2 --- And answer 5 1 5 2 8 9 3 11 12 3 14 15 3 19 20 4 GOOD LUCK! My Program passed all tests in this board, but hic...hic.. still got WA#10, what in this test! Give me the test#10 please !!! I think it's simple to model this process, but I got WA10. Could you help me? Give me some tests, please. I tried all tests from forum and my program gives right answers at all of them. Edited by author 21.02.2006 21:46 Me too,and I have passed all tests from forum. I used two suffix array which contains sorted dictionary words something need to take care: 1.if the readed word's lengh is within [1, 8] 2.if you found one in dictionary, make sure they have the same length and exact one letter different 3.The word readed in may contains only a single character Test 1. Need three tickets -> 3 * 4 = 12 And need money (two tickets) for first pessenger for distance from 1 to 4. All sum = 12 + 2 * 4 = 20. Please, tell me, what I dont understand. Sorry, I bad speak english. this not test 1, example test!!! From 1 to 4: 3 ticket Two people in 4 don't need! 3*4=12 i mean like this: 4 3 3 1 2 150 <----this stop is greater than 100 2 2 3 2 3 4 3 27 1 0 15 4 0 45 4 0
4 3 3 1 2 4 2 2 3 2 3 4 3 27 1 0 15 4 0 45 4 0 The answer is 4 4. Am right)? I have "crach(access violation)" on Test 5. Can't repeat it my self! I think my algorithm is quite right: I use dynamic programming. It seems that I've mistaken with some special cases... Don't know what to do... I've reviewed the code plenty times... Test 5 must have something wrong!!!!! you must sort the result of the first presentation ! This code get 0.001 int main() { int n, i, k, m[]={ 0, here must be numberz :) }; // 39 numbers scanf("%d",&k); for(i=0;i<k;i++) { scanf("%d",&n); printf("%d\n",m[n]); } return 0; } and this code get 0.015 int main() { int n, i, k, m[]={here must be numberz :) }; // 38 numbers scanf("%d",&k); for(i=0;i<k;i++) { scanf("%d",&n); printf("%d\n",m[n-1]); } return 0; } Why 38 iterations of (n-1) so hardly influence for speed of execution ??? Edited by author 02.05.2007 01:47 It is not a problem of time, your program is good.You have different time because the server was checking another solution with yours |
|