|
336 | 336 | }, |
337 | 337 | { |
338 | 338 | "cell_type": "code", |
339 | | - "execution_count": 3, |
| 339 | + "execution_count": 1, |
340 | 340 | "metadata": {}, |
341 | 341 | "outputs": [ |
342 | 342 | { |
343 | | - "data": { |
344 | | - "text/plain": [ |
345 | | - "[[1, 1], [1, 2], [4, 6], [2, 1], [9, 6], [9, 3], [4, 3]]" |
346 | | - ] |
347 | | - }, |
348 | | - "execution_count": 3, |
349 | | - "metadata": {}, |
350 | | - "output_type": "execute_result" |
351 | | - } |
352 | | - ], |
353 | | - "source": [ |
354 | | - "l" |
355 | | - ] |
356 | | - }, |
357 | | - { |
358 | | - "cell_type": "code", |
359 | | - "execution_count": 8, |
360 | | - "metadata": {}, |
361 | | - "outputs": [ |
| 343 | + "name": "stdin", |
| 344 | + "output_type": "stream", |
| 345 | + "text": [ |
| 346 | + " 1\n", |
| 347 | + " 2\n", |
| 348 | + " 1 1\n", |
| 349 | + " 1 2\n", |
| 350 | + " 4 6\n", |
| 351 | + " 2 1\n", |
| 352 | + " 9 6\n", |
| 353 | + " 9 3\n", |
| 354 | + " 4 3\n" |
| 355 | + ] |
| 356 | + }, |
362 | 357 | { |
363 | 358 | "name": "stdout", |
364 | 359 | "output_type": "stream", |
365 | 360 | "text": [ |
366 | | - "2 2\n" |
| 361 | + "2 2 \n" |
367 | 362 | ] |
368 | 363 | } |
369 | 364 | ], |
370 | 365 | "source": [ |
371 | | - "for i,j in zip(l1,l2):\n", |
372 | | - " if l1.count(i)%2==1:\n", |
373 | | - " x=i\n", |
374 | | - " if l2.count(j)%2==1:\n", |
375 | | - " y=j\n", |
376 | | - "print(x,y)" |
| 366 | + "from functools import reduce\n", |
| 367 | + "for _ in range(int(input())):\n", |
| 368 | + " n=int(input())\n", |
| 369 | + " l1=[]\n", |
| 370 | + " l2=[]\n", |
| 371 | + " for i in range(4*n-1):\n", |
| 372 | + " m,n=map(int,input().split())\n", |
| 373 | + " l1.append(m) \n", |
| 374 | + " l2.append(n)\n", |
| 375 | + " print(reduce(lambda x, y: x ^ y,l1),reduce(lambda x, y: x ^ y,l2))" |
377 | 376 | ] |
378 | 377 | }, |
379 | 378 | { |
380 | | - "cell_type": "code", |
381 | | - "execution_count": 5, |
| 379 | + "cell_type": "markdown", |
382 | 380 | "metadata": {}, |
383 | | - "outputs": [ |
384 | | - { |
385 | | - "data": { |
386 | | - "text/plain": [ |
387 | | - "[1, 1, 4, 2, 9, 9, 4]" |
388 | | - ] |
389 | | - }, |
390 | | - "execution_count": 5, |
391 | | - "metadata": {}, |
392 | | - "output_type": "execute_result" |
393 | | - } |
394 | | - ], |
395 | 381 | "source": [ |
396 | | - "l1" |
| 382 | + "# [Doctor Chef](https://www.codechef.com/JULY20B/problems/DRCHEF)" |
397 | 383 | ] |
398 | 384 | }, |
399 | 385 | { |
400 | 386 | "cell_type": "code", |
401 | | - "execution_count": 6, |
| 387 | + "execution_count": 1, |
402 | 388 | "metadata": {}, |
403 | 389 | "outputs": [ |
404 | 390 | { |
405 | | - "data": { |
406 | | - "text/plain": [ |
407 | | - "[1, 2, 6, 1, 6, 3, 3]" |
408 | | - ] |
409 | | - }, |
410 | | - "execution_count": 6, |
411 | | - "metadata": {}, |
412 | | - "output_type": "execute_result" |
| 391 | + "name": "stdin", |
| 392 | + "output_type": "stream", |
| 393 | + "text": [ |
| 394 | + " 1\n", |
| 395 | + " 5 1\n", |
| 396 | + " 40 30 20 10 50\n" |
| 397 | + ] |
| 398 | + }, |
| 399 | + { |
| 400 | + "name": "stdout", |
| 401 | + "output_type": "stream", |
| 402 | + "text": [ |
| 403 | + "49\n", |
| 404 | + "47\n", |
| 405 | + "43\n", |
| 406 | + "35\n", |
| 407 | + "19\n", |
| 408 | + "10\n" |
| 409 | + ] |
413 | 410 | } |
414 | 411 | ], |
415 | 412 | "source": [ |
416 | | - "l2" |
| 413 | + "for _ in range(int(input())):\n", |
| 414 | + " n1,n2=map(int,input().split())\n", |
| 415 | + " a=list(map(int,input().split()))\n", |
| 416 | + " c=len(a)\n", |
| 417 | + " m=max(a)\n", |
| 418 | + " if (m-n2)>0:\n", |
| 419 | + " m-=n2\n", |
| 420 | + " n2*=2\n", |
| 421 | + " while m>0:\n", |
| 422 | + " c+=1\n", |
| 423 | + " print(m)\n", |
| 424 | + " if (m-n2)>0:\n", |
| 425 | + " m-=n2\n", |
| 426 | + " n2*=2\n", |
| 427 | + " else:\n", |
| 428 | + " break\n", |
| 429 | + " print(c)\n", |
| 430 | + " else:\n", |
| 431 | + " print(c)" |
417 | 432 | ] |
418 | 433 | }, |
419 | 434 | { |
420 | 435 | "cell_type": "code", |
421 | | - "execution_count": 14, |
| 436 | + "execution_count": 2, |
422 | 437 | "metadata": {}, |
423 | 438 | "outputs": [ |
424 | 439 | { |
425 | 440 | "data": { |
426 | 441 | "text/plain": [ |
427 | | - "'89'" |
| 442 | + "10" |
428 | 443 | ] |
429 | 444 | }, |
430 | | - "execution_count": 14, |
| 445 | + "execution_count": 2, |
431 | 446 | "metadata": {}, |
432 | 447 | "output_type": "execute_result" |
433 | 448 | } |
434 | 449 | ], |
435 | 450 | "source": [ |
436 | | - "s='789'\n", |
437 | | - "s=s.replace('7','')\n", |
438 | | - "s" |
| 451 | + "c" |
| 452 | + ] |
| 453 | + }, |
| 454 | + { |
| 455 | + "cell_type": "markdown", |
| 456 | + "metadata": {}, |
| 457 | + "source": [ |
| 458 | + "<div class=\"LI-profile-badge\" data-version=\"v1\" data-size=\"medium\" data-locale=\"en_US\" data-type=\"horizontal\" data-theme=\"dark\" data-vanity=\"keshavsingh4522\"><a class=\"LI-simple-link\" href='https://in.linkedin.com/in/keshavsingh4522?trk=profile-badge'>Keshav Singh</a></div>" |
439 | 459 | ] |
440 | 460 | }, |
441 | 461 | { |
|
0 commit comments