পৃষ্ঠাসমূহ

শনিবার, ৬ মে, ২০১৭

uva 113

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package uva100;

import java.util.Scanner;

class Main {

    public static void main(String[] args) {
       
        Scanner scanner = new Scanner(System.in);
       
        while (scanner.hasNextDouble()) {
            double n = scanner.nextDouble();
       
            double p = scanner.nextDouble();
       
            System.out.printf("%.0f\n",Math.pow(p, (1/n)));
        }
       
     
       
    }
}

uva 108

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package uva100;

import java.util.Scanner;

class Main {

    public static void main(String[] args) {
       
        Scanner scanner = new Scanner(System.in);
        int i,j, max = 0;
       
        int n = scanner.nextInt();
       
        int arr[][] = new int[n][n];
        for (i=0; i<n; i++) {
            for (j=0;j<n;j++) {
                arr[i][j] = scanner.nextInt();
            }
        }
        max = arr[0][0];
       
        for (int leftCol=0;leftCol<n;leftCol++) {
            int[] tempArr = new int[n];
            for (int rightCol=leftCol;rightCol<n;rightCol++) {
                for (i=0;i<n;i++) {
                    tempArr[i] += arr[i][rightCol];
                }
                int maximum = maxincolumn(tempArr);
                if (maximum > max) {
                    max = maximum;
                }
            }
           
        }
      System.out.println(max);
    }
   
    static int maxincolumn(int col[]) {
        int max = col[0];
        for (int i=0;i<col.length;i++) {
            int temp = 0;
            for (int j=i;j<col.length;j++) {
                temp += col[j];
                if (temp > max) {
                    max = temp;
                }
            }
        }
       
        return max;
    }
}

uva 102

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package uva100;

import java.util.Scanner;

class Main {

    public static void main(String[] args) {
     
        Scanner scanner = new Scanner(System.in);
        int b1b, b1g, b1c, b2b, b2g, b2c, b3b, b3g, b3c;
        int bgc, bcg, gbc, gcb, cbg, cgb;
        int minimum;
        String comb;
        while(scanner.hasNextInt()) {
            b1b = scanner.nextInt();
            b1g = scanner.nextInt();
            b1c = scanner.nextInt();
            b2b = scanner.nextInt();
            b2g = scanner.nextInt();
            b2c = scanner.nextInt();
            b3b = scanner.nextInt();
            b3g = scanner.nextInt();
            b3c = scanner.nextInt();
           
            bcg = b2b + b3b + b1c + b3c + b1g + b2g;
            bgc = b2b + b3b + b1c + b2c + b1g + b3g;
         
            gbc = b1b + b3b + b1c + b2c + b3g + b2g;
            gcb = b1b + b2b + b1c + b3c + b3g + b2g;
         
            cbg = b1b + b3b + b2c + b3c + b1g + b2g;
            cgb = b1b + b2b + b2c + b3c + b3g + b1g;
         
            minimum = bcg;
            comb = "BCG";
         
            if (bgc < minimum) {
                minimum = bgc;
                comb = "BGC";
            }
         
            if (cbg < minimum) {
                minimum = cbg;
                comb = "CBG";
            }
         
            if (cgb < minimum) {
                minimum = cgb;
                comb = "CGB";
            }
         
            if (gbc < minimum) {
                minimum = gbc;
                comb = "GBC";
            }
         
            if (gcb < minimum) {
                minimum = gcb;
                comb = "GCB";
            }
         
         
         
            System.out.println(comb + " "+minimum);
        }
    }
}

uva 100

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package uva100;

import java.util.Scanner;

class Main {

    public static void main(String[] args) {
       
        Scanner scanner = new Scanner(System.in);
        int i,j,c, max = 0, first, last;
        while(scanner.hasNextInt()) {
            i=scanner.nextInt();
            j=scanner.nextInt();
            max = 0;
            if (j>i) {
                first = i;
                last = j;
            } else {
                first = j;
                last = i;
            }
       
            for (int start = first; start<=last; start++) {
                c = 1;
               
                int num = start;
                while (num != 1) {
                    c++;
           
                    if (num % 2 == 1){
                        num = (3*num) + 1;
                    } else {
                        num = num / 2;
                    }
                }
                if (c > max) max = c;
            }
            System.out.println(i + " " + j + " "+ max);
        }
    }
}