Pages

Sunday, December 27, 2009

Java Compiler (jdk1.5)

u can download the java compiler jdk1.5 from the link given below. please try again later if it shows "the file is temporarily unavailable".
da link must work.

click here to download

Java Compiler (jdk1.5)

u can download the java compiler jdk1.5 from the link given below. please try again later if it shows "the file is temporarily unavailable".
da link must work.

click here to download

Thursday, October 22, 2009

UVA Problem#11530


Question:
http://uva.onlinejudge.org/external/115/11530.html

Solution:
int main(){
.....
..... 

if(s[j]=='a' || s[j]=='d' || s[j]=='g' || s[j]=='j' || s[j]=='m' 
|| s[j]=='p' || s[j]=='t' || s[j]=='w' || s[j]==' '){
c += 1;
}else if(s[j]=='b' || s[j]=='e' || s[j]=='h' || s[j]=='k' 
|| s[j]=='n' || s[j]=='q' || s[j]=='u' || s[j]=='x'){
c += 2;
}else if(s[j]=='c' || s[j]=='f' || s[j]=='i' || s[j]=='l' || 
s[j]=='o' || s[j]=='r' || s[j]=='v' || s[j]=='y'){
c += 3;
}else{
c += 4;
}
....
.... 
 
}


UVA Problem#10222

Question:

Solutions :
#include<stdio.h>
#include<string.h>

void pri(char c){
if(c == ']'){
printf("p");
}else if(c == '['){
printf("o");
}else if(c == 'p' || c == 'P'){
printf("i");
}else if(c == 'o' || c == 'O'){
printf("u");
}else if(c == 'i' || c == 'I'){
printf("y");
}else if(c == 'u' || c == 'U'){
printf("t");
}else if(c == 'y' || c == 'Y'){
printf("r");
}else if(c == 't' || c == 'T'){
printf("e");
}else if(c == 'r' || c == 'R'){
printf("w");
}else if(c == 'e' || c == 'E'){
printf("q");
}else if(c == '\''){
printf("l");
}else if(c == ';'){
printf("k");
}else if(c == 'l' || c == 'L'){
printf("j");
}else if(c == 'k' || c == 'K'){
printf("h");
}else if(c == 'j' || c == 'J'){
printf("g");
}else if(c == 'h' || c == 'H'){
printf("f");
}else if(c == 'g' || c == 'G'){
printf("d");
}else if(c == 'f' || c == 'F'){
printf("s");
}else if(c == 'd' || c == 'D'){
printf("a");
}else if(c == '.'){
printf("m");
}else if(c == ','){
printf("n");
}else if(c == 'm' || c == 'M'){
printf("b");
}else if(c == 'n' || c == 'N'){
printf("v");
}else if(c == 'b' || c == 'B'){
printf("c");
}else if(c == 'v' || c == 'V'){
printf("x");
}else if(c == 'c' || c == 'C'){
printf("z");
}else if(c == 's' || c == 'S'){
printf("]");
}else if(c == 'a' || c == 'A'){
printf("[");
}else if(c == 'x' || c == 'X'){
printf("\\");
}else if(c == 'z' || c == 'Z'){
printf("\'");
}
}

UVA Problem#10018

Question:

Solutions :
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

char s1[100], s[100], s2[100];

void add(char f[], char s[], char r[]){
int lf, ls, d=0, i, j=0, c=0, sum;
lf=strlen(f); ls=strlen(s);
reverse(f, f+lf); reverse(s, s+ls);
if(lf>=ls){
d=lf-ls;
for(i=0; i<ls; i++){
sum = f[i]+s[i]-96+c;
r[j++] = (sum%10)+48;
c = sum/10;
}
for(i=ls; i<lf; i++){
sum = f[i]-48+c;
r[j++] = (sum%10)+48;
c = sum/10;
}
if(c!=0){
sum = c%10;
r[j++] = sum+48;
if(c>9)r[j++] = (c/10)+48;
}
r[j] = '\0';
lf = strlen(r);
reverse(r, r+lf);
}else{
d=lf-ls;
for(i=0; i<lf; i++){
sum = f[i]+s[i]-96+c;
r[j++] = (sum%10)+48;
c = sum/10;
}
for(i=lf; i<ls; i++){
sum = s[i]-48+c;
r[j++] = (sum%10)+48;
c = sum/10;
}
if(c!=0){
sum = c%10;
r[j++] = sum+48;
if(c>9)r[j++] = (c/10)+48;
}
r[j] = '\0';
lf = strlen(r);
reverse(r, r+lf);
}
}

UVA Problem#543

Question:

Solutions :
#include<stdio.h>
#include<math.h>

int prime(int n){
int i, c=1, j=int(sqrt(n));
for(i=2; i<=j; i++){
if(n%i==0){
c = 0;
break;
}
}
return c;
}

UVA Problem#458

Question:

Solutions :
#include<stdio.h>
#include<string.h>

char s[1000000];

int main(){
int i, l, c;
while(gets(s) != NULL){
l = strlen(s);
for(i=0; i<l; i++){
c = s[i]-7;
printf("%c", c);
}
printf("\n");
}
return 0;
}

UVA Problem#424

Question:

Solution: 
char f[100000], s[100000], r[100000]; 
void add(char f[], char s[], char r[]){ 
int lf, ls, d, i, j=0, c=0, sum; lf=strlen(f);
ls=strlen(s); 
reverse(f, f+lf); 
reverse(s, s+ls); 

UVA Problem#382

Question:

Solution: 
void perfection(int n){
int i , sum=0, m=n/2; 
for(i=1; i<=m; i++){ 
if(n%i==0)
sum += i; 
}
if(n>sum){ 
printf("DEFICIENT\n"); 
}
else if(n<sum){ 
printf("ABUNDANT\n"); 
}
else if(n == sum){
printf("PERFECT\n"); 
}
  int main(){
....
.... 
}  

Friday, October 9, 2009

The Art of Computer Programming by Donald E. Knuth (Boxed_Set_Vol_1-4.part2)

The Art of Computer Programming by Donald E. Knuth. The link to download the 2nd part of the book is given below.

click here to download

The Art of Computer Programming by Donald E. Knuth (Boxed_Set_Vol_1-4.part2)

The Art of Computer Programming by Donald E. Knuth. The link to download the 2nd part of the book is given below.

click here to download

The Art of Computer Programming by Donald E. Knuth (Boxed_Set_Vol_1-4.part1)

The Art of Computer Programming by Donald E. Knuth. Here is the link to download the 1st part.


click here to download

A Computational Introduction To Number Theory And Algebra

A Computational Introduction to Number Theory by Victor Shoup

click here to download

Password to unzip/unrar: www.ebooksdb.com

Thursday, October 8, 2009

UVA Problem#10432

Question:

Solution technique: 
1. take inputs 
2. define pi as acos(-1.0) 
3. use the formula below to find the output:
area = (n*r*r*(sin(2.0*pi/n)))/2; 
  

UVA Problem#10370

Question:

Solution:
1. take inputs c, n, and the numbers in an array a[]
2. add all the elements of the array and find the average.
3. now check for the following condition and print the result:

int main(){
....
..... 
for(j=0; j>n; j++){ 
if(a[j]<avg)count++; 
r = (count/n)*100; 
printf("%.3lf%c\n", r, d);   
 }

Wednesday, October 7, 2009

Big Mod (uva#374)

Question:

Solutions :
long bigmod(long b, long p, long m){
if(p==0)
return 1;
else if(p%2==0)
return ((bigmod(b, (p/2), m))*(bigmod(b, (p/2), m)))%m;
else return((b%m)*bigmod(b, p-1, m))%m;
}
  

Fibonacci using quick matrix

Solutions :

int fibo(int n){       // using quick method matrix program
int i, h, j, k, t;
i=h=1;
j=k=0;
while(n>0){
if(n%2==1){
t=j*h;
j=i*h + j*k +t;
i= i*k + t;
}
t= h*h;
h=2*h*k + t;
k= k*k +t;
n= (int) n/2;
}
return j;
}

Fibonacci using dynamic program

Solutions :

int fibo(int n){      // // using dynamic program
int a=1, b=1, i, c;
for(i=2; i>=n; i++){
c=a+b;
a=b;
b=c;
}
return a;
}

Fibonacci using normal recursion

Solutions :

int fibo(int n){    // using normal recursion
if(n<2) return (fibo(n-1)+fibo(n-2));
if(n==0) return 0;
else return (1);
}

Ins and outs of Fibonacci numbers

here is a describe document on fibonacci number. Almost everything of it....

click here to view/download

Ins and outs of Fibonacci numbers

here is a describe document on fibonacci number. Almost everything of it....

click here to view/download

Divisibility rules

here is another important topics on the various rules of divisibility.

click here to download

Divisibility rules

here is another important topics on the various rules of divisibility.

click here to download

Bit wise operator

Using of Bit wise operators instead of any other mathematical operators is much more faster. here is a document of its uses.

click here to download

Bit wise operator

Using of Bit wise operators instead of any other mathematical operators is much more faster. here is a document of its uses.

click here to download

Monday, October 5, 2009

Programming Challenges- the Programming Contest Training Manual

Programming Challenges- the Programming Contest Training Manual by Steven S.Skiena and Miguel A.Revilla.

click here to download

Java 2-The Complete Reference (fifth edition)-Herbert Schildt

 Java 2-The Complete Reference (fifth edition)-Herbert Schildt........another useful book to learn JAVA language.

click here to download

UVA Problem#100

Question:

Solution:
1. take input i, j. let x=i, y=j. 
2. Generate the series.
for(a=i; a<=j; a++){ 
n=a; 
count=1; 
while(n!=1){
if(n%2==0){ 
n = n/2; 
}
else{ 
n = 3*n+1; 
count++; 
}  

3. find the max count value by 
if(maxcount < count){ 
maxcount=count; 

JAVA How to Program (7th Edition) by Deitel and Deitel

A complete java book full of examples. "JAVA How to Program (7th Edition) by Deitel and Deitel".

click here to download

Sunday, September 20, 2009

UVA Problem#10055

Question:

Solution:
int main(){
...
... 
if(a>b) 
d=(a-b); 
else d=(b-a);  
...
...

Saturday, September 19, 2009

UVA Problem#10812

Question:
http://uva.onlinejudge.org/external/108/10812.html 

Solution:
1. run the loop down to n
2. take the input s and d.
3. Print the output using this technique:        
if(s<d || (s+d)%2 || (s-d)%2)
            printf("impossible\n");
        else{
            a=(s+d)/2;
            b=(s-a);
            if(a>b)
                printf("%d %d\n", a, b);
            else
                printf("%d %d\n", b, a);
        }
 

Thursday, September 17, 2009

UVA Problem#11185

Question:

Solution Techniques:
 1. take input.
2. use the following formula to get the ternary of the number

ternary[i] = decimal%3; 
decimal = decimal/3; 
i++;

3. Show the output. 

UVA Problem#10071

#include <stdio.h>

int main(){
int v, t;
while(scanf("%d%d", &v, &t)==2)
printf("%d\n", 2*v*t);
return 0;
}

Wednesday, September 16, 2009

UVA Problem#11172

Question:
http://uva.onlinejudge.org/external/111/11172.html 

Solution Method:
it is one of the most easiest problem of UVA. 
1. take simple input 
2. bye simple comparing you can achieve the proper output.


UVA Problem#11636

Question:
http://uva.onlinejudge.org/external/116/11636.html 

Solution: 
int main(){ 
...
..... 
scanf("%d", &n); 
if(n<0) break; 
if(n>1){
j = 0; 
line = 1; 
for(j=1; ; j++){
line *= 2; 
if(line >= n) break; 
}
  ....
....} 

UVA Problem#10783

Question:

Solution Method:
 1. loop will run from the given starting value till the gien end value
2. check for the odd numbers
3. simply add them 

UVA Problem#575

Question:
http://uva.onlinejudge.org/external/5/575.html 

Solution:
int main(){
.....
.... 
for(i=0; i<l; i++){
            s=1;
            for(j=l; j>i; j--){
                s*=2;
            }
   
            k+=((a[i]-48)*(s-1));
        }

......
..... 


UVA Problem#438

Question:

Solution:
int main(){
.....
.... 
m1= (y2-y1)/(x2-x1); 
m2= (y3-y1)/(x3-x1); 
if (m2==0){
  k= (x2-x3)/m1/2 + (y1+y2)/2; 
h= (x1+x3)/2; }
if (m1==0){
  k=(x3-x2)/m2/2 + (y1+y3)/2; 
h=(x1+x2)/2; 
}
else if (m1!=0&&m2!=0){ 
h= ((x1+x2)/m1 - (x1+x3)/m2 + y2-y3)/2/(1/m1 - 1/m2);
  k= ( h-(x1+x2)/2)/(-m1) + (y1+y2)/2; 
}
r= sqrt((h-x1)*(h-x1) + (k-y1)*(k-y1)); 
ans=2*pi*r;   
......
...

UVA Problem#369

Question:

Solution: 
double fact(int n){ 
int i; double f=1; 
for(i=2; i<=n; i++){ 
f = f*i; 
return f; 
}
int main(){ 
....
.... 
c = fact(n) / ( fact(n-m) * fact(m) ) 
... 
}



UVA Problem#113

Question: 

Solution:
y=exp((1/n)*log(p)); 

Friday, September 11, 2009

Addison-Wesley_Concrete.Mathematics

An essential book for solving the program related to mathematics! Very usefull though very difficult!!
click here to download

Wednesday, September 9, 2009

Introduction to Algorithm-Cormen

A book of algorithm by Cormen. Algorithms are must to do well in any kind of programming contest.
 
click here to download

Art of Programming Contest

A wonderful book for the amateur contestant. This book is a must to know all the ABC of a programming contest.

Thursday, August 27, 2009

Peter Norton- 2nd Edition

A book by Peter Norton. Basically used in computer fundamental learning.

click here to download

Peter Norton- 2nd Edition

A book by Peter Norton. Basically used in computer fundamental learning.

click here to download

C Programming- A book from oxford

A Programming Book from OXFORD university! A small book but very useful for learning.

click here to download

C Programming for the absolute Beginner

C Programming For The Absolute Beginner is a very useful book for the beginner!

click here to download

Programming with C- Schaum Series

Programming with C- Schaum Series is amongst the mostly used book to learn 'C' language! its a very useful book!
click here to download

ANSI C programming language- Brian W Kernighan & Dennies M Ritchie

Legend of the 'C' Language! Kernighan and Ritchie!! Its a book from them

click here to download