by Muhammad Harun-Or-Roshid | Feb 7, 2019 | Problem Solving, URI
URI Problem (Column in Array) 1182:
Column in Array 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 27, 2016
* @Time : 9:20:17 PM
*/
public class Uri1182 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double ars[][] = new double[12][12];
int l = sc.nextInt();
String s = sc.next();
double sum = 0;
if (l >= 0 && l <= 11) {
for (int i = 0; i < ars.length; i++) {
for (int j = 0; j < ars.length; j++) {
ars[i][j] = sc.nextDouble();
if (l == j) {
sum += ars[i][j];
}
}
}
if ("S".equals(s)) {
System.out.printf("%.1f\n", sum);
} else if ("M".equals(s)) {
System.out.printf("%.1f\n", (sum / 12));
}
}
}
}
by Muhammad Harun-Or-Roshid | Feb 7, 2019 | Problem Solving, URI
URI Problem (Line in Array) 1181:
Line in Array 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 : [email protected]
* @Date : Oct 27, 2016
* @Time : 8:57:36 PM
*/
public class Uri1181 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double ars[][] = new double[12][12];
int l = sc.nextInt();
String s = sc.next();
double sum = 0;
if (l >= 0 && l <= 11) {
for (int i = 0; i < ars.length; i++) {
for (int j = 0; j < ars.length; j++) {
ars[i][j] = sc.nextDouble();
if (l == i) {
sum += ars[i][j];
}
}
}
if("S".equals(s)){
System.out.printf("%.1f\n",sum);
}else if("M".equals(s)){
System.out.printf("%.1f\n",(sum/12));
}
}
}
}
by Muhammad Harun-Or-Roshid | Feb 7, 2019 | Problem Solving, URI
URI Problem (Lowest Number and Position) 1180:
Lowest Number 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 27, 2016
* @Time : 8:30:34 PM
*/
public class Uri1180 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int value = 0, position = 0;
int n = sc.nextInt();
if (1 < n && n < 1000) {
int ars[] = new int[n];
for (int i = 0; i < ars.length; i++) {
ars[i] = sc.nextInt();
if(value>ars[i]){
value=ars[i];
position= i;
}
}
System.out.println("Menor valor: "+value+"\n"+"Posicao: "+position);
}
}
}
by Muhammad Harun-Or-Roshid | Feb 7, 2019 | Problem Solving, URI
URI Problem (Array Fill IV) 1179:
Sum of Consecutive Even Numbers 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 27, 2016
* @Time : 10:58:46 PM
*/
public class Uri1179 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int par[] = new int[5];
int impar[] = new int[5];
int p = 0;
int im = 0;
for (int i = 0; i < 15; i++) {
int x = sc.nextInt();
if (x % 2 == 0) {
par[p] = x;
p++;
} else {
impar[im] = x;
im++;
}
if (p == 5) {
int c = 0;
while (c < p) {
System.out.println("par[" + c + "] = " + par[c]);
c++;
}
p = 0;
}
if (im == 5) {
int d = 0;
while (d < im) {
System.out.println("impar[" + d + "] = " + impar[d]);
d++;
}
im = 0;
}
if (i == 14) {
int d = 0;
while (d < im) {
System.out.println("impar[" + d + "] = " + impar[d]);
d++;
}
int c = 0;
while (c < p) {
System.out.println("par[" + c + "] = " + par[c]);
c++;
}
}
}
}
}
by Muhammad Harun-Or-Roshid | Feb 7, 2019 | Problem Solving, URI
URI Problem (Sum of Consecutive Even Numbers) 1159:
Sum of Consecutive Even Numbers 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 22, 2016
* @Time : 11:34:44 AM
*/
public class Uri1159 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int x = sc.nextInt();
int count = 0, total = 0;
if (x == 0) {
break;
} else {
while (count < 5) {
if (x % 2 == 0) {
total += x;
count++;
}
x++;
}
System.out.println(total);
}
}
}
}
by Muhammad Harun-Or-Roshid | Feb 7, 2019 | Problem Solving, URI
URI Problem (Sum of Consecutive Odd Numbers III) 1158:
Sum of Consecutive Odd Numbers III 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 21, 2016
* @Time : 11:12:29 PM
*/
public class Uri1158 {
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,total = 0;
while(y>count){
if(x%2!=0){
total+=x;
count++;
}
x++;
}
System.out.println(total);
}
}
}
by Muhammad Harun-Or-Roshid | Feb 7, 2019 | Problem Solving, URI
URI Problem (Divisors I) 1157:
Divisors I 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 21, 2016
* @Time : 11:06:28 PM
*/
public class Uri1157 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i = 1; i <= n; i++) {
if(n%i==0){
System.out.println(i);
}
}
}
}
by Muhammad Harun-Or-Roshid | Feb 7, 2019 | Problem Solving, URI
URI Problem (S Sequence II) 1156:
S Sequence II is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.
/**
* @Author : Muhammad Harun-Or-Roshid
* @Date : Oct 21, 2016
* @Time : 10:53:21 PM
*/
public class Uri1156 {
public static void main(String[] args) {
double total = 0;
int count = 1;
for (int i = 1; i <= 39; i+=2) {
double s = (double)i/(double)(count);
total+=s;
count*=2;
}
System.out.printf("%.2f\n",total);
}
}
by Muhammad Harun-Or-Roshid | Feb 7, 2019 | Problem Solving, URI
URI Problem (S Sequence) 1155:
S Sequence is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.
/**
* @Author : Muhammad Harun-Or-Roshid
* @Date : Oct 21, 2016
* @Time : 10:27:56 PM
*/
public class Uri1155 {
public static void main(String[] args) {
double total = 0;
for (int i = 1; i <= 100; i++) {
double p = 1 / (double) i;
total += p;
}
System.out.printf("%.2f\n", total);
}
}
by Muhammad Harun-Or-Roshid | Feb 7, 2019 | Problem Solving, URI
URI Problem (Ages) 1154:
Ages 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 : [email protected]
* @Date : Oct 21, 2016
* @Time : 10:20:55 PM
*/
public class Uri1154 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int total = 0, count = 0 ;
while(true){
int age = sc.nextInt();
if(age<0){
break;
}else{
total+=age;
count++;
}
}
double x = total/(double)count;
System.out.printf("%.2f\n",x);
}
}
by Muhammad Harun-Or-Roshid | Feb 5, 2019 | Problem Solving, URI
URI Problem (Simple Factorial) 1153:
Simple Factorial 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 21, 2016
* @Time : 10:08:20 PM
*/
public class Uri1153 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String value = br.readLine().trim();
int x = Integer.valueOf(value);
if (x > 0 && x < 13) {
bw.write(getFactorial(x)+"\n");
bw.flush();
}
bw.close();
br.close();
}
private static int getFactorial(int x) {
if (x == 1) {
return 1;
} else {
return x * getFactorial(x - 1);
}
}
}
by Muhammad Harun-Or-Roshid | Feb 5, 2019 | Problem Solving, URI
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();
}
}
}
by Muhammad Harun-Or-Roshid | Feb 5, 2019 | Problem Solving, URI
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();
}
}
by Muhammad Harun-Or-Roshid | Feb 5, 2019 | Problem Solving, URI
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 : [email protected]
* @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);
}
}
by Muhammad Harun-Or-Roshid | Feb 5, 2019 | Problem Solving, URI
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();
}
}
by Muhammad Harun-Or-Roshid | Feb 5, 2019 | Problem Solving, URI
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("");
}
}
}
}
by Muhammad Harun-Or-Roshid | Feb 5, 2019 | Problem Solving, URI
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;
}
}
}
}
by Muhammad Harun-Or-Roshid | Feb 5, 2019 | Problem Solving, URI
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 : [email protected]
* @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);
}
}
}
}
by Muhammad Harun-Or-Roshid | Feb 5, 2019 | Problem Solving, URI
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 : [email protected]
* @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;
}
}
}
by Muhammad Harun-Or-Roshid | Feb 5, 2019 | Problem Solving, URI
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);
}
}