Saturday, September 19, 2015

Digital Logic And Computer Design By M. Morris Mano


                                     Digital Logic And Computer Design By M. Morris Mano (2nd Edition)
                                                         Digital Logic & Computer Design 4th
                                Digital Logic and Computer Design 4th by m. morris mano solution manual
                                                   Digital-Logic-Design-Morris-Mano-Solution

Digital Systems Principles and Applications 8th Edition Ronald J. Tocci, Neal S. Widmer, Gregory L. Moss

Modern Digital Electronics RP JAIN 3rd and 4th Edition

Digital Systems Principles and Applications 10th Edition Ronald J. Tocci, Neal S. Widmer, Gregory L. Moss

                                                                      Download Link

Modern Operating Systems 4th Edition ,ANDREW S.TANENBAUM

                                                          Download Link 4th edition

                                                             Download 2nd Edition


Operating System Concepts 9thEdition , Abraham Silberschatz, Peter Baer Galvin & Greg Gagne





                                                               Only Book Download Link pdf

                                                        Book and Exercise File and Solution pdf




Thursday, September 17, 2015

UVA-100 - The 3n + 1 problem Using Java and C

 

100 - The 3n + 1 problem
Time limit: 3.000 seconds

The 3n + 1 problem

Background

Problems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this problem you will be analyzing a property of an algorithm whose classification is not known for all possible inputs.

The Problem

Consider the following algorithm:

 
1. input n


2. print n


3. if n = 1 then STOP


4. if n is odd then tex2html_wrap_inline44


5. else tex2html_wrap_inline46


6. GOTO 2



Given the input 22, the following sequence of numbers will be printed 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1

It is conjectured that the algorithm above will terminate (when a 1 is printed) for any integral input value. Despite the simplicity of the algorithm, it is unknown whether this conjecture is true. It has been verified, however, for all integers n such that 0 < n < 1,000,000 (and, in fact, for many more numbers than this.)

Given an input n, it is possible to determine the number of numbers printed (including the 1). For a given n this is called the cycle-length of n. In the example above, the cycle length of 22 is 16.

For any two numbers i and j you are to determine the maximum cycle length over all numbers between i and j.


The Input


The input will consist of a series of pairs of integers i and j, one pair of integers per line. All integers will be less than 1,000,000 and greater than 0.

You should process all pairs of integers and for each pair determine the maximum cycle length over all integers between and includingi and j.

You can assume that no operation overflows a 32-bit integer.

The Output


For each pair of input integers i and j you should output i, j, and the maximum cycle length for integers between and including i and j. These three numbers should be separated by at least one space with all three numbers on one line and with one line of output for each line of input. The integers i and j must appear in the output in the same order in which they appeared in the input and should be followed by the maximum cycle length (on the same line).

Sample Input

1 10
100 200
201 210
900 1000

Sample Output

1 10 20
100 200 125
201 210 89
900 1000 174

Using Java


import java.util.Scanner;
 
public class Main{
     static long cou(long  n)
    {
 
       if (n==1)
        return 1;
       else if(n%2!=0)
       {
           return cou(3*n+1)+1;
       }
       else
       {
           return cou(n/2)+1;
       }
    }
      static long abc(long  a,long  b)
     {
         if(b<a)
         {
             return abc( b, a);
         }
 
          long count=0,ln;
        while(a<=b)
        {
          ln=cou(a);
            if(ln>count)
            {
                count=ln;
            }
            a++;
        }
        return count;
     }
    
    public static void main(String[] args) {
         long a,b;
         Scanner s=new Scanner(System.in);
         while(s.hasNext())
         {
             a=s.nextLong();
             b=s.nextLong();
             System.out.println(a+" "+b+" "+abc(a,b));
         }
    }
 
}


Using C



#include<stdio.h>
long long cou(long long n)
{
 
   if (n==1)
    return 1;
   else if(n%2!=0)
   {
       return cou(3*n+1)+1;
   }
   else
   {
       return cou(n/2)+1;
   }
}
long long abc(long long a,long long b)
{
    if(b<a)
    {
        return abc( b, a);
    }
 
    long long count=0,ln;
   while(a<=b)
   {
     ln=cou(a);
       if(ln>count)
       {
           count=ln;
       }
       a++;
   }
   return count;
}
int main()
{
    long long a,b;
    while(scanf("%lld%lld",&a,&b)!=EOF)
    {
        printf("%lld %lld %lld\n",a,b,abc(a,b));
    }
    return 0;
}

UVA-382–Perfection- Using java And C

UVA-382–Perfection- Using java

382 - Perfection
Time limit: 3.000 seconds

Perfection

From the article Number Theory in the 1994 Microsoft Encarta: ``If a, b, c are integers such that a = bc, a is called a multiple of b or ofc, and b or c is called a divisor or factor of a. If c is not tex2html_wrap_inline41 , b is called a proper divisor of a. Even integers, which include 0, are multiples of 2, for example, -4, 0, 2, 10; an odd integer is an integer that is not even, for example, -5, 1, 3, 9. A perfect number is a positive integer that is equal to the sum of all its positive, proper divisors; for example, 6, which equals 1 + 2 + 3, and 28, which equals 1 + 2 + 4 + 7 + 14, are perfect numbers. A positive number that is not perfect is imperfect and is deficient or abundant according to whether the sum of its positive, proper divisors is smaller or larger than the number itself. Thus, 9, with proper divisors 1, 3, is deficient; 12, with proper divisors 1, 2, 3, 4, 6, is abundant."

Problem Statement

Given a number, determine if it is perfect, abundant, or deficient.

Input

A list of N positive integers (none greater than 60,000), with 1 < N < 100. A 0 will mark the end of the list.

Output

The first line of output should read PERFECTION OUTPUT. The next N lines of output should list for each input integer whether it is perfect, deficient, or abundant, as shown in the example below. Format counts: the echoed integers should be right justified within the first 5 spaces of the output line, followed by two blank spaces, followed by the description of the integer. The final line of output should read END OF OUTPUT.

Sample Input

15 28 6 56 60000 22 496 0

Sample Output

PERFECTION OUTPUT
15 DEFICIENT
28 PERFECT
6 PERFECT
56 ABUNDANT
60000 ABUNDANT
22 DEFICIENT
496 PERFECT
END OF OUTPUT

 

Using Java



import java.util.Scanner;
public class Main {
 
    public static void main(String[] args) {
        int a;
        System.out.println("PERFECTION OUTPUT");
        Scanner s=new Scanner(System.in);
         while(s.hasNext())
         {
             a=s.nextInt();
             if(a==0)
                {
                 System.out.println("END OF OUTPUT");
                    break;
                }
             int n=a,i,sum=0;
             for(i=1;i<a;i++)
             {
                 if(n%i==0)
                 sum=sum+i;
             }
             if(sum==a)
             {    
                 
                 System.out.format("%5d  PERFECT\n", a);
             }
             else if(sum>a)
             {    
                 
                 System.out.format("%5d  ABUNDANT\n", a);
             }
             else if(sum<a)
             {    
                 
                 System.out.format("%5d  DEFICIENT\n", a);
             }
 
         }
         }
        
        
    }
 


Using C



#include<stdio.h>
int main()
{
     int a;
     printf("PERFECTION OUTPUT\n");
     while(scanf("%d",&a)!=EOF)
     {
            if(a==0)
            {
                printf("END OF OUTPUT\n");
                break;
            }
            int n=a,i,sum=0;
         for(i=1;i<a;i++)
         {
             if(n%i==0)
             sum=sum+i;
         }
         if(sum==a)
         {
             printf("%5d PERFECT\n",a);
         }
         else if(sum>a)
         {
             printf("%5d ABUNDANT\n",a);
         }
         else if(sum<a)
         {
             printf("%5d DEFICIENT\n",a);
         }
 
     }
    return 0;
 
}

UVA - 136 - Ugly Numbers Using Java

136 - Ugly Numbers

Ugly Numbers

Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence

1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ...

shows the first 11 ugly numbers. By convention, 1 is included.

Write a program to find and print the 1500'th ugly number.

Input and Output

There is no input to this program. Output should consist of a single line as shown below, with <number> replaced by the number computed.

Sample output

The 1500'th ugly number is <number>.

public class Main{
 
    public static void main(String[] args) {
        System.out.println("The 1500'th ugly number is 859963392.");
 
    }
 
}