## Sunday, February 1, 2015

### Getting Started: Competitive Programming

How to start?
http://blog.hackerearth.com/2013/09/competitive-programming-getting-started_11.html
http://www.codeabbey.com/index/task_list(Good collection of problems)

Puzzles:
http://n1b-algo.blogspot.in

## Saturday, August 23, 2014

### Divisibility check for very very large numbers. Find whether a ^ b is divisible by c ^ d. (a ^ b : a raised to the power of b)

Given very very large numbers a, b, c, d.Find whether a^b is divisible by c^d. (pow in c++)
Constraints:  1 <= a, b, c , d <= 10^16
Let x = (a^b) / (c^d)  where x is some integer obtained after division.

Applying log on both sides,

log(x) = log( (a^b) / (c^d) )
= log(a^b) - log(c^d)
= b log a - d log c
Now, x = exp(b log a - d log c) [where exp (in c++)Returns the base-e exponential function of x, which is e raised to the power x: `ex`.]
Finally check, whether x is an integer or not.

C++ Implementation:
/*
Author: Prasad SVD
Definitions:
a^b -> a raised to the power of b
a^b -> pow(a, b) in C++ defined in cmath library
*/
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
long long int a, b, c, d;
double quotient;
int  T;
cin >> T;
while(T > 0)
{
cin >> a >> b >> c >> d;
if(!d)
{
cout<<"a^b is Divisible by c^d"<<endl;
}
else
{
quotient = exp((b*log(a))-(d*log(c)));
cout<<quotient<<endl;
if(quotient - (int)quotient != 0)
cout<<"a^b is Not Divisible by c^d"<<endl;
else
cout<<"a^b is Divisible by c^d"<<endl;
}
--T;
}
return 0;
}

## Monday, May 27, 2013

### Pamper Yourself

1. Run yourself a hot bath, but not too hot! Pregnant women should not take hot baths. Remove your jewelry and put it into a jewelry cleaner. Put your clothes into a laundry basket. Make sure the bath tub is very clean. No mess beats an organized clean living space. Do not stay in the bath for more than 20 minutes.

2. Dim the lights in your bathroom so it's darker or just go by candle light. Reflective glass, colored glass, and mirrors can be a huge help to add to the feel of a temple.

3. Get in the bath and forget all your worries. Take a waterproof pillow to support your head (bath pillows sold at many retailers). If you like, massage your scalp and neck touching acupressure points. Use an exfoliation brush to remove dead skin to show your beautiful glowing skin underneath that has just grown there like a fresh baby. Cleopatra put milk into her bath, some celebrities use wine, some use bath bombs, olive oil, coconut oil, etc. Do not ball your hair up when you wash it, use a wide tooth comb or your finger nails and gently massage your head. Do not make it tangled! It helps to have your bathroom scented with a slowly burning essential oil or by a oxygen rejuvenating machine that lets steam gently float around the room.

4. When you are feeling fully relaxed and clean get out of the bath and pat dry yourself with a big soft towel. Wax your legs or underarms if you prefer, it keeps the hair off longer. Rub a hair mask into your hair and use a warming face mask for the face. Afterward, use olive oil on the face rubbing your face gently.

5. Apply some nice lotion to make your skin feel soft. Princess Diana used almond oil while her skin was still wet. You can scent this oil with any pure essential oil scent. If you like, go back into a shower now to rinse off switching from hot to cold until your skin is rosy and pink. Afterwards, hop out and rub a thick lotion into your skin starting at the toes extending to the feet, ankles, calves, knees, under the thigh, the top of the thigh, the hips, the buttocks, the waist, the belly, the breasts, the collar bone, the neck, behind the neck, the shoulders, the back the arms, the elbow, the wrists, and from hand to hand massaging the hands. Roll your neck and stretch your back.

6. Put on some comfy pajamas and a dressing gown. Looking pretty in a gown helps, splurge on a nice dressing gown or pajamas. Dress for bed like you would dress for a ball.

7. Paint your nails and toenails. When they dry put a clear coat so the nail polish wont start chipping as quickly. Try coconut oil on your nails, it will help them grow and keep them nice. If you prefer, use a nail polish without the bad ingredients in it...you'll find at a health store. Trimming your nails keeps you from getting grime under the nail bed. Filing your nails works too.

8. Make yourself a nice hot drink e.g. hot chocolate. If you drink green tea, it has fluoride in it and will make your teeth whiter, plus, it's healthier. Add lemon to it and your body will absorb the calcium. Add honey to it and your body will absorb energy in terms of carbohydrates and sugars. If you drink hot chocolate go without milk like the Aztecs did and just drink the cocoa with hot water and some chili powder. It'll spice up your palate and be a good diuretic if you're constipated.

9. Drink your drink in bed. Have a bed in breakfast small table over you while you sip tea or another hot beverage or a smoothie veggie or fruit, nuts, eat a yummy salad with lots of color in it. Eat some grains if you like, maybe a flax muffin or "bliss balls." It's a good idea to use a silk or satin pillow as this will keep your hair from being damaged.

10. Watch TV or a film or listen to some relaxing music in your bed Try listening to an audio book or if you have someone who will read to you, it can be nice. A book tightly shut is just a block of paper. Maybe read an inspirational book, some Chinese proverbs, or reflect on your new year's goals. Write in your journal or diary. Keep it by your bedside to write in it in the morning so you can listen and pay attention to that inner voice using at least 3 pages of free writing. Place a hot heating pad under or over irritated muscles or joints. Rub chap stick into your soft lips. It's a good idea to chew on fruits, veggies, and nuts in the meanwhile.

11. When the film/music has finished turn off the TV/stereo. Turn on a light that makes it look like stars are on your ceiling and walls. It can be very calming to feel like a galaxy is in your bedroom. Soft star like lights are proven to help children sleep easier at night and get over fear of the dark. Keep a small fountain of flowing water by your bed, or fish swimming in a fish tank, and listen to the sound of the rustling water. Before you fall asleep, make sure you are not angry. If you must, cry and let it out. Do what you feel is best to not be angry before bed.

12. Turn out the lights in your bedroom and think of relaxing or calming thoughts until you fall asleep. Chamomile tea will help you sleep. Holding something will also help such as a long body pillow, a teddy bear, your pet animal, or your love. If you like, say a prayer.

# I can't maximize videos to full screen on sites such as Youtube (Just a white screen appears, with background sound).

1. Right-click in the standard youtube video window (non-full screen).
2. Choose 'Settings...' from the Flash Player's pop-up menu.
3. Uncheck the 'Enable Hardware Acceleration'
4. Click 'Close'.

# Easy Steps for Installation:

1.Install Java Development kit(JDK).
2.Install eclipse and extract to new (safe) directory.(eclipse.org/mobile)
3.Run Eclipse >> Help >> Install New Software >> Add>>
4.Type "ADT Plugin" in name:
a.If NOT protected by firewall or proxy then Enter "http://dl-ssl.google.com/android/eclipse/" in site location:
b.Else Download the ADT Plugin zip file ADT ZIP FILE (DO NOT UNPACK it) and click archive,set appropriate location of zip file.
5.Wait until all the children are fetched.(Check bottom right fetching children)
6.In the Available Software dialog, select the check box next to Developer Tools and click Next.
7.Finish,Restart Eclipse and START ANDROID programming.
8.Happy coding!!!

Useful Links:
ANDROID DEVELOPERS

Common BUGS:
1.DUPLICATE LOCATION:While adding site location.
solution....Window>>Preferences>>Available Softwares>>Uncheck the sites or Reload

2.If your system is protected from proxy server/Firewall.
CONFIGURE PROXY..Window>>Preferences>>Network Settings>>Authenticate

## Sunday, January 6, 2013

### Why we shout in anger?

"Why We Shout In Anger"

A Hindu saint who was visiting river Ganges to take bath found a group of family members on the banks, shouting in anger at each other. He turned to his disciples smiled'n asked.

'Why do people in anger shout at each other?'

Disciples thought for a while, one of them said,'Because we lose our calm, we shout.'

'But, why should you shout when the other person is just next to you? You can as well tell him what you have to say in a soft manner.'asked the saint

Disciples gave some other answers but none satisfied the other disciples.

Finally the saint explained...

'When two people are angry at each other, their hearts distance a lot. To cover that distance they must shout to be able to hear each other. The angrier they are, the stronger they will have to shout to hear each other to cover that great distance. What happens when two people fall in love? They don't shout at each other but talk softly, Because their hearts are very close. The distance between them is either nonexistent or very small...'

The saint continued,'When they love each other even more, what happens? They do not speak, only whisper'n they get even closer to each other in their love. Finally they even need not whisper, they only look at each other'n that's all. That is how close two people are when they love each other.'

He looked at his disciples and said.

'So when you argue do not let your hearts get distant, Do not say words that distance each other more, Or else there will come a day when the distance is so great that you will not find the path to return.'

## Friday, December 21, 2012

### Favourite Quotes

Let each man exercise the art he knows.
Aristophanes

Judge each day not by the harvest you reap but by the seeds you plant.
Robert Louis Stevenson

In a gentle way, you can shake the world.
Mohandas Gandhi

Ideas shape the course of history.
John Maynard Keynes

Change your thoughts and you change your world.
Norman Vincent Peale

Great hopes make great men.
Thomas Fuller

You have to dream before your dreams can come true.
Abdul Kalam

Wherever you are - be all there.
Jim Elliot

Always bear in mind that your own resolution to succeed is more important than any other.
Abraham Lincoln

Be sure you put your feet in the right place, then stand firm.
Abraham Lincoln

Give me six hours to chop down a tree and I will spend the first four sharpening the axe.
Abraham Lincoln

I do the very best I know how - the very best I can; and I mean to keep on doing so until the end.
Abraham Lincoln

I like to see a man proud of the place in which he lives. I like to see a man live so that his place will be proud of him.
Abraham Lincoln

I will prepare and some day my chance will come.
Abraham Lincoln

I'm a slow walker, but I never walk back.
Abraham Lincoln

If there is anything that a man can do well, I say let him do it. Give him a chance.
Abraham Lincoln

That some achieve great success, is proof to all that others can achieve it as well.
Abraham Lincoln

The things I want to know are in books; my best friend is the man who'll get me a book I ain't read.
Abraham Lincoln

To sin by silence when they should protest makes cowards of men.
Abraham Lincoln

Whatever you are, be a good one.
Abraham Lincoln

When I do good, I feel good. When I do bad, I feel bad. That's my religion.
Abraham Lincoln

You cannot build character and courage by taking away a man's initiative and independence.
Abraham Lincoln

You have to do your own growing no matter how tall your grandfather was.
Abraham Lincoln

The truest wisdom is a resolute determination.
Napoleon Bonaparte