URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Easy Fibonacci) 1151:
Easy Fibonacci is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 20, 2016
 * @Time : 12:40:59 PM
 */
public class Uri1151 {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int previous = 0;
        int current = 1;
        int x = Integer.valueOf((br.readLine()).trim());
        if (x > 0 && x < 46) {
            if (x == 1) {
                bw.write("" + previous);
            } else if(x==2){
                bw.write("" + previous + " " + current);
            }else{
                bw.write("" + previous + " " + current + " ");
            }

            for (int i = 0; i <= (x - 3); i++) {
                int newCurrent = (previous + current);
                bw.write(newCurrent + "");
                previous = current;
                current = newCurrent;
                if (i == (x - 3)) {

                } else {
                    bw.write(" ");
                }
                bw.flush();
            }   
            bw.write("\n");
            bw.close();
            br.close();
        }
    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Exceeding Z) 1150 Solution in Java

URI Problem (Exceeding Z) 1150:
Exceeding Z is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 20, 2016
 * @Time : 12:09:55 PM
 */
public class Uri1150 {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int a, n, sec = 0, total = 0;
        a = getIntInput(br);
        while ((n = getIntInput(br)) <= a);
        do {
            total += a;
            a++;
            sec++;
        } while (total < n);
        printValue(bw, String.valueOf(sec));
        printValue(bw, "\n");
        
        br.close();
        bw.close();
    }
    
    private static int getIntInput(BufferedReader br) throws IOException {
        int x = Integer.valueOf((br.readLine()).trim());
        return x;
    }
    
    private static void printValue(BufferedWriter bw, String string) throws IOException {
        bw.write(string);
        bw.flush();
        
    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Summing Consecutive Integers) 1149 Solution in Java

URI Problem (Summing Consecutive Integers) 1149:
Summing Consecutive Integers is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @E-mail : md.parvez28@gmail.com
 * @Date : Oct 19, 2016
 * @Time : 11:48:52 PM
 */
public class Uri1149 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a, n,b=0;
        a = sc.nextInt();
        while((n=sc.nextInt())<=0);
        for (int i = 1; i <= n; i++) {
            b+=a;
            a++;
        }
        System.out.println(b);
    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Growing Sequences) 1146 Solution in Java

URI Problem (Growing Sequences) 1146:
Growing Sequences is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 19, 2016
 * @Time : 11:10:08 PM
 */
public class Uri1146 {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int x;
        while ((x = getIntInput(br)) != 0) {
            for (int i = 1; i < x; i++) {
                printValue(bw, i + " ");
            }
            printValue(bw, x+"\n");
        }
        br.close();
        bw.close();
    }

    private static int getIntInput(BufferedReader br) throws IOException {
        int x = Integer.valueOf((br.readLine()).trim());
        return x;
    }

    private static void printValue(BufferedWriter bw, String string) throws IOException {
        bw.write(string);
        bw.flush();

    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Logical Sequence 2) 1145 Solution in Java

URI Problem (Logical Sequence 2) 1145:
Logical Sequence 2 is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 19, 2016
 * @Time : 2:02:59 AM
 */
public class Uri1145 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        if (x > 1 && x < 20 && y > x && y < 100000) {
            for (int i = 1; i <=y; i++) {
                System.out.print(i);
                if(i%x==0){
                    System.out.println("");
                }else{
                    System.out.print(" ");
                }
            }
            if(y%x!=0){
                System.out.println("");
            }
            
        }
    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Logical Sequence) 1144 Solution in Java

URI Problem (Logical Sequence) 1144:
Logical Sequence is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 19, 2016
 * @Time : 1:47:58 AM
 */
public class Uri1144 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n >= 1 && n <= 1000) {
            int a = 1, b = 1;
            for (int i = 1; i <= n; i++) {
                int c = a * b;
                System.out.println(a + " " + b + " " + c);
                System.out.println(a + " " + (++b) + " " + (c + 1));
                a++;
                b += i * 2;
            }
        }
    }

}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Squared and Cubic) 1143 Solution in Java

URI Problem (Squared and Cubic) 1143:
Squared and Cubic is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @E-mail : md.parvez28@gmail.com
 * @Date : Oct 19, 2016
 * @Time : 1:32:10 AM
 */
public class Uri1143 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n >= 1 && n <= 1000) {
            for (int i = 1; i <= n; i++) {
                int sq = (int) Math.pow(i, 2);
                int malti = i * sq;
                System.out.println(i + " " + sq + " " + malti);
            }
        }
    }

}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (PUM) 1142 Solution in Java

URI Problem (PUM) 1142:
PUM is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @E-mail : md.parvez28@gmail.com
 * @Date : Oct 19, 2016
 * @Time : 1:20:39 AM
 */
public class Uri1142 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int p =0 ;
        for (int i = 0; i <n; i++) {
            System.out.println((p+1)+" "+(p+2)+" "+(p+3)+" PUM");
            p+=4;
        }
    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Type of Fuel) 1134 Solution in Java

URI Problem (Type of Fuel) 1134:
Type of Fuel is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 19, 2016
 * @Time : 1:00:43 AM
 */
public class Uri1134 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int alcohol = 0, gasoline = 0, diesel = 0;
        while (true) {
            int x = sc.nextInt();
            if (x == 4) {
                break;
            } else if (x == 1) {
                alcohol++;
            } else if (x == 2) {
                gasoline++;
            } else if (x == 3) {
                diesel++;
            }          
        }
        System.out.println("MUITO OBRIGADO");
        System.out.println("Alcool: " + alcohol);
        System.out.println("Gasolina: " + gasoline);
        System.out.println("Diesel: " + diesel);
    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Rest of a Division) 1133 Solution in Java

URI Problem (Rest of a Division) 1133:
Rest of a Division is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 19, 2016
 * @Time : 12:55:22 AM
 */
public class Uri1133 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        if (x > y) {
            int temp = x;
            x = y;
            y = temp;
        }
        for (int i = (x+1); i < y; i++) {
            if (i % 5 == 2 || i % 5 == 3) {
                System.out.println(i);
            }

        }

    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Multiples of 13) 1132 Solution in Java

URI Problem (Multiples of 13) 1132:
Multiples of 13 is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 19, 2016
 * @Time : 12:46:16 AM
 */
public class Uri1132 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int total = 0;
        int x = sc.nextInt();
        int y = sc.nextInt();
        if(x>y){
            int temp = x;
            x = y;
            y = temp;
        }
        for (int i = x; i <= y; i++) {
            if(i%13!=0){
                total+=i;
            }
        }
        System.out.println(total);
    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Grenais) 1131 Solution in Java

URI Problem (Grenais) 1131:
Grenais is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 19, 2016
 * @Time : 12:28:53 AM
 */
public class Uri1131 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int inter = 0, gremio = 0, empates = 0;
        int total = 0;
        int p = 1;
        do {
            if (p == 1) {
                total++;
                int i = sc.nextInt();
                int g = sc.nextInt();
                if (i > g) {
                    inter++;
                } else if (g > i) {
                    gremio++;
                } else {
                    empates++;
                }
            }
            System.out.println("Novo grenal (1-sim 2-nao)");
            p = sc.nextInt();
        } while (p != 2);

        System.out.println(total + " grenais");
        System.out.println("Inter:" + inter);
        System.out.println("Gremio:" + gremio);
        System.out.println("Empates:" + empates);
        if (inter > gremio) {
            System.out.println("Inter venceu mais");
        } else if (inter < gremio) {
            System.out.println("Gremio venceu mais");
        } else {
            System.out.println("Nao houve vencedor");
        }
    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Several Scores with Validation) 1118 Solution in Java

URI Problem (Several Scores with Validation) 1118:
Several Scores with Validation is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 19, 2016
 * @Time : 12:07:13 AM
 */
public class Uri1118 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int p = 1;
        while (p != 2) {
            if (p ==1) {
                int count = 0;
                double total = 0;
                while (count != 2) {
                    double x = sc.nextDouble();
                    if (x >= 0 && x <= 10) {
                        total += x;
                        count++;
                    } else {
                        System.out.println("nota invalida");
                    }
                }
                System.out.printf("media = %.2f\n", (total / count));
            }
            System.out.println("novo calculo (1-sim 2-nao)");
            p = sc.nextInt();
        }
    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Score Validation) 1117 Solution in Java

URI Problem (Score Validation) 1117:
Score Validation is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 18, 2016
 * @Time : 11:57:21 PM
 */
public class Uri1117 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        double total = 0;
        while (count != 2) {
            double x = sc.nextDouble();
            if (x >= 0 && x <= 10) {
                total += x;
                count++;
            } else {
                System.out.println("nota invalida");
            }
        }
        System.out.printf("media = %.2f\n",(total/count));
    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Dividing X by Y) 1116 Solution in Java

URI Problem (Dividing X by Y) 1116:
Dividing X by Y is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 18, 2016
 * @Time : 11:42:47 PM
 */
public class Uri1116 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (y == 0) {
                System.out.println("divisao impossivel");
            } else {
                System.out.printf("%.1f\n", ((double) x / y));
            }
        }
    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Quadrant) 1115 Solution in Java

URI Problem (Quadrant) 1115:
Quadrant is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 18, 2016
 * @Time : 12:17:36 PM
 */
public class Uri1115 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (x == 0 && y == 0) {
                break;
            } else if (x > 0 && y > 0) {
                System.out.println("primeiro");
            } else if (x > 0 && y < 0) {
                System.out.println("quarto");
            } else if (x < 0 && y < 0) {
                System.out.println("terceiro");
            } else if (x < 0 && y > 0) {
                System.out.println("segundo");
            }
        }
    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Fixed Password) 1114 Solution in Java

URI Problem (Fixed Password) 1114:
Fixed Password is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 18, 2016
 * @Time : 11:55:58 AM
 */
public class Uri1114 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int password;
        do {
            password = sc.nextInt();
            if (password == 2002) {
                System.out.println("Acesso Permitido");
            } else {
                System.out.println("Senha Invalida");
            }
        }while(password!=2002);

    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Ascending and Descending) 1113 Solution in Java

URI Problem (Ascending and Descending) 1113:
Ascending and Descending is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 17, 2016
 * @Time : 8:14:17 PM
 */
public class Uri1113 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            if(x==y){
                break;
            }else if(x>y){
                System.out.println("Decrescente");
            }else{
                System.out.println("Crescente");
            }
        }
    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Sequence of Numbers and Sum) 1101:
Sequence of Numbers and Sum is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 17, 2016
 * @Time : 8:00:38 PM
 */
public class Uri1101 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int count = 0;

            if (x <= 0 || y <= 0) {
                break;
            }
            if (x > y) {
                int temp = x;
                x = y;
                y = temp;
            }
            for (int i = x; i <= y; i++) {
                count += i;
                System.out.print(i + " ");
            }
            System.out.println("Sum=" + count);
        }
    }
}
URI Problem (Easy Fibonacci) 1151 Solution in Java

URI Problem (Sum of Consecutive Odd Numbers II) 1099 Solution in Java

URI Problem (Sum of Consecutive Odd Numbers II) 1099:
Sum of Consecutive Odd Numbers II is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 17, 2016
 * @Time : 7:44:30 PM
 */
public class Uri1099 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int count = 0;
            if (x > y) {
                int temp = x;
                x = y;
                y = temp;
            }
            for (int j = (x + 1); j < y; j++) {
                if (j % 2 != 0) {
                    count += j;
                }
            }
            System.out.println(count);
        }
    }
}