Sunday, September 29, 2013

15567. Playing With Balls

IITKWPCN

   There are W white balls and B black balls in a bag. A magician is performing tricks by drawing balls from the bag.

    In each step, the magician randomly removes any two balls from the bag. If the drawn balls are of the same color, he will put one white ball in the bag, otherwise he will put a black ball in it. The two drawn balls from the bag from the ball are discarded.
    He keeps on doing the above tricks until there is only one ball remaining in the bag.
    Given W and B, you have to determine the probability that the color of last ball remaining in the bag is black. You should print the answer with accuracy of upto 6 decimal digits.

CODE

 

t=input()
for i in range(t):
    s=raw_input()
    str=s.split(' ')
    w=int(str[0])
    b=int(str[1])
    c=b%10
    if(b%2==0):
        print("0.000000")
    else:
        print("1.000000")
 


 



7430. Tower Of Hanoi - Revisited

Given 3 three pegs: leftmost peg A, middle peg B and rightmost peg C.Find the shortest sequence of moves that transfers a tower of n disks from the left peg A to the right peg C, if direct moves between A and C are disallowed. (Each move must be to or from the middle peg B.)

Constraints:
1. Initially the left peg A in stacked by n disks in the order of decreasing size.
2. Only one move cand be done at a time and never moving a larger one onto a smaller.
3. Number of moves will always be less than 2^64.
4. 1 <= n <= 35


CODE

t=input()
for i in range(t):
    a=input()
    print (3**a-1)

Sunday, September 15, 2013

<data:blog.pageName/> |<data:blog.title/>ubuntu proxy setting linux proxy setting "proxy-setter" ubuntu ubuntu 13.04 ubuntu 12.10 ubuntu 12.04 ubuntu 11.10 linux python proxy apt-get http https ftp gtk tool <data:blog.pageTitle/>ubuntu proxy setting linux proxy setting "proxy-setter" ubuntu ubuntu 13.04 ubuntu 12.10 ubuntu 12.04 ubuntu 11.10 linux python proxy apt-get http https ftp gtk tool "ubuntu proxy setting"
"linux proxy setting"
"proxy-setter"
"ubuntu" "ubuntu 13.04" "ubuntu 12.10" "ubuntu 12.04" "ubuntu 11.10"
"linux"
"python" "proxy apt-get"
"http" "https" "ftp" "gtk tool"


#!/usr/bin/python
#
#   "Super Proxy Setter"
#   with GTK Interface
#
#   Ubuntu proxy setting tool.
#   This sets the apt,bash and profile config-files.
#   Network proxy-settings with user-name and password can only be configured with this tool .
#  
#   Supports Ubuntu 8.04 - Ubuntu 13.04 (Latest as of Sep 2013)

#   A tool to configure proxy-settings in universities and office environmment.
#   It Eliminates the need of doint editing again and again of system files that is prone to frequent manual errors. 
#   Atleast 3 different configuration files needs to be modified to configure proxy settings,
#   especially the network proxy-settings with username and password.
#   This can be used in an environment where ("http","https" and the "ftp") proxies have the same or different settings.
#  
#
#
#
#   Author:  Abdul Qadir Faridi , Pankaj Chaudhary
#
#   E-mail:  aqfaridi[@]gmail[.]com , pankaj9310[@]gmail[.]com
#
#   Date:    16/9/2013
#   Meta:  
#            Abdul Qadir Faridi , Pankaj Chaudhary
#            Linux Community
#            ABV - Indian Institute of Information Technology and Management - Gwalior
#
#   Powered By:
#               Ubuntu 11.10 & Vi IMproved 7.3
#  
#
#   Ver.- 1.0.0
#
#   ReadMe -  1) chmod 777 spsetter
#          2) sudo ./spsetter   
#
https://github.com/pankaj9310/proxy-setter
https://github.com/aqfaridi/super-proxy-setter/blob/master/spsetter.py
https://www.dropbox.com/sh/uv6ig21btedm1kb/ppXbABcSHJ
https://www.dropbox.com/sh/uv6ig21btedm1kb/DkskxPzBIt/spsetter.zip
https://www.dropbox.com/home/proxy-setter?select=spsetter.tar.gz