URI Problem (Rest of a Division) 1133 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 (Multiples of 13) 1132 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 (Grenais) 1131 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 (Several Scores with Validation) 1118 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 (Score Validation) 1117 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 (Dividing X by Y) 1116 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 (Quadrant) 1115 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 (Fixed Password) 1114 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 (Ascending and Descending) 1113 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 (Sequence of Numbers and Sum) 1101 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 (Sum of Consecutive Odd Numbers II) 1099 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);
        }
    }
}
URI Problem (Sequence IJ 4) 1098 Solution in Java

URI Problem (Sequence IJ 4) 1098 Solution in Java

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

import java.text.DecimalFormat;

/**
 * @E-mail : [email protected]
 * @Date : Oct 16, 2016
 * @Time : 11:28:50 PM
 */
public class Uri1098 {

    public static void main(String[] args) {
        for (double i = 0; i <= 2; i += 0.2) {
            System.out.println("I=" + go(toDouble(i)) + " J=" + go(toDouble(i + 1)));
            System.out.println("I=" + go(toDouble(i)) + " J=" + go(toDouble(i + 2)));
            System.out.println("I=" + go(toDouble(i)) + " J=" + go(toDouble(i + 3)));
        }
    }

    private static String go(double d) {
        if (d == (int) d) {
            return "" + (int) d;
        } else {
            return "" + d;
        }
    }

    private static double toDouble(double x) {
        DecimalFormat format = new DecimalFormat("#0.0");
        return Double.valueOf(format.format(x));
    }
}
URI Problem (Sequence IJ 3) 1097 Solution in Java

URI Problem (Sequence IJ 3) 1097 Solution in Java

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

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @E-mail : [email protected]
 * @Date : Oct 16, 2016
 * @Time : 11:24:10 PM
 */
public class Uri1097 {

    public static void main(String[] args) {
        int p = 7;
        for (int i = 1; i < 10; i += 2) {
            for (int j = p; j >= p-2; j--) {
                System.out.println("I=" + i + " J=" + j);
            }
            p+=2;
        }
    }
}
URI Problem (Sequence IJ 2) 1096 Solution in Java

URI Problem (Sequence IJ 2) 1096 Solution in Java

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

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @E-mail : [email protected]
 * @Date : Oct 16, 2016
 * @Time : 11:12:17 PM
 */
public class Uri1096 {

    public static void main(String[] args) {
        for (int i = 1; i < 10; i += 2) {
            for (int j = 7; j >= 5; j--) {
                System.out.println("I=" + i + " J=" + j);
            }
        }
    }
}
URI Problem (Sequence IJ 1) 1095 Solution in Java

URI Problem (Sequence IJ 1) 1095 Solution in Java

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

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @E-mail : [email protected]
 * @Date : Oct 16, 2016
 * @Time : 10:47:47 PM
 */
public class Uri1095 {

    public static void main(String[] args) {
        int i = 1;
        for (int j = 60; j >= 0; j-=5) {
            System.out.println("I="+i+" J="+j);
            i+=3;
        }
    }
}
URI Problem (Experiments) 1094 Solution in Java

URI Problem (Experiments) 1094 Solution in Java

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

import java.text.DecimalFormat;
import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 15, 2016
 * @Time : 3:24:24 PM
 */
public class Uri1094 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String value;
        String values[];
        int n = sc.nextInt();
        int c = 0, r = 0, s = 0, total = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            String b = sc.next();
            if (a >= 1 && a <= 15) {
                if (b.equalsIgnoreCase("C")) {
                    c += a;
                }
                if (b.equalsIgnoreCase("R")) {
                    r += a;
                }
                if (b.equalsIgnoreCase("S")) {
                    s += a;
                }
                total += a;
            }
        }
        double c_c = toDouble((c / (double) total) * 100.00);
        double c_r = toDouble((r / (double) total) * 100.00);
        double c_s = toDouble((s / (double) total) * 100.00);

        System.out.println("Total: " + total + " cobaias");
        System.out.println("Total de coelhos: " + c);
        System.out.println("Total de ratos: " + r);
        System.out.println("Total de sapos: " + s);

        System.out.printf("Percentual de coelhos: %.2f %%\n", c_c);
        System.out.printf("Percentual de ratos: %.2f %%\n", c_r);
        System.out.printf("Percentual de sapos: %.2f %%\n", c_s);

    }

    private static double toDouble(double x) {
        DecimalFormat format = new DecimalFormat("#0.00");
        return Double.valueOf(format.format(x));
    }
}
URI Problem (Highest and Position) 1080 Solution in Java

URI Problem (Highest and Position) 1080 Solution in Java

URI Problem (Highest and Position) 1080:
Highest and Position 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 15, 2016
 * @Time : 1:34:13 PM
 */
public class Uri1080 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int values[] = new int[100];
        int value = 0, index = 0;

        for (int i = 0; i < 100; i++) {
            values[i] = sc.nextInt();
            if (values[i] > value) {
                value = values[i];
                index = i;
            }
        }
        System.out.println(value);
        System.out.println((index + 1));

    }
}
URI Problem (Weighted Averages) 1079 Solution in Java

URI Problem (Weighted Averages) 1079 Solution in Java

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

import java.text.DecimalFormat;
import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 15, 2016
 * @Time : 1:23:20 PM
 */
public class Uri1079 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = 2, b = 3, c = 5;
        for (int i = 0; i < n; i++) {
            double x = sc.nextDouble();
            double y = sc.nextDouble();
            double z = sc.nextDouble();
            System.out.println(toDouble(((x * a) + (y * b) + (z * c)) / (a + b + c)));
        }
    }

    private static double toDouble(double x) {
        DecimalFormat format = new DecimalFormat("#0.0");
        return Double.valueOf(format.format(x));
    }
}
URI Problem (Multiplication Table) 1078 Solution in Java

URI Problem (Multiplication Table) 1078 Solution in Java

URI Problem (Multiplication Table) 1078:
Multiplication Table 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 15, 2016
 * @Time : 1:16:50 PM
 */
public class Uri1078 {

    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 <= 10; i++) {
                System.out.println(i + " x " + n + " = " + (i * n));
            }
        }
    }
}
URI Problem (Remaining 2) 1075 Solution in Java

URI Problem (Remaining 2) 1075 Solution in Java

URI Problem (Remaining 2) 1075:
Remaining 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 15, 2016
 * @Time : 1:08:11 PM
 */
public class Uri1075 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n < 10000) {
            for (int i = 1; i <= 10000; i++) {
                if (i % n == 2) {
                    System.out.println(i);
                }
            }
        }
    }
}