 ## URI Problem (To Carry or not to Carry) 1026 Solution in Java

URI Problem (To Carry or not to Carry) 1026:
To Carry or not to Carry is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

```import java.util.Scanner;

/**
* @Date : Oct 15, 2016
* @Time : 4:22:27 PM
*/
public class Uri1026 {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
x = sc.nextLong();
y = sc.nextLong();
}
}
}```

First of all we have to take two 32 bit decimal numbers as input, and produce an unsigned 32 bit decimal number as the output.
– In above program we take x and y as input and answer as output.
– We have to take x and y value from user and convert them into 32 bit binary.
– And then we have to XOR them and convert to decimal number.
– And after that we put it in answer variable and print it. In java programming there is bitwise XOR operator which is ^ . We solved this problem very easily using this bitwise XOR operator. ## URI Problem (Right Area) 1190 Solution in Java

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

```import java.util.Scanner;

/**
* @Date   : Oct 28, 2016
* @Time   : 4:04:11 PM
*/
public class Uri1190 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double m[][] = new double;
double sum = 0;
int count = 0;
String v = sc.next();
for (int i = 0; i < m.length; i++) {
for (int j = 0; j < m.length; j++) {
double x = sc.nextDouble();
m[i][j] = x;
if (j > m.length - i - 1 && i < j) {
sum += x;
count++;
}
}

}
if (v.equals("S")) {
System.out.printf("%.1f\n", sum);
} else {
System.out.printf("%.1f\n", (sum / count));
}
}
}``` ## URI Problem (Left Area) 1189 Solution in Java

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

```import java.util.Scanner;

/**
* @Date : Oct 28, 2016
* @Time : 3:57:00 PM
*/
public class Uri1189 {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double m[][] = new double;
double sum = 0;
int count = 0;
String v = sc.next();
for (int i = 0; i < m.length; i++) {
for (int j = 0; j < m.length; j++) {
double x = sc.nextDouble();
m[i][j] = x;
if (j < m.length - i - 1 && i > j) {
sum += x;
count++;
}
}

}
if (v.equals("S")) {
System.out.printf("%.1f\n", sum);
} else {
System.out.printf("%.1f\n", (sum / count));
}
}
}``` ## URI Problem (Inferior Area) 1188 Solution in Java

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

```import java.util.Scanner;

/**
* @Date : Oct 28, 2016
* @Time : 3:45:36 PM
*/
public class Uri1188 {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double m[][] = new double;
double sum = 0;
int count = 0;
String v = sc.next();
for (int i = 0; i < m.length; i++) {
for (int j = 0; j < m.length; j++) {
double x = sc.nextDouble();
m[i][j] = x;

if (j < i && j > (m.length - i - 1)) {
sum += x;
count++;
}
}

}
if (v.equals("S")) {
System.out.printf("%.1f\n", sum);
} else {
System.out.printf("%.1f\n", (sum / count));
}
}
}``` ## URI Problem (Top Area) 1187 Solution in Java

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

```import java.util.Scanner;

/**
* @Date : Oct 28, 2016
* @Time : 3:32:36 PM
*/
public class Uri1187 {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double m[][] = new double;
double sum = 0;
int count = 0;
String v = sc.next();
for (int i = 0; i < m.length; i++) {
for (int j = 0; j < m.length; j++) {
double x = sc.nextDouble();
m[i][j] = x;

if (j > i && j < (m.length - i - 1)) {
sum += x;
count++;
}
}
}
if (v.equals("S")) {
System.out.printf("%.1f\n", sum);
} else {
System.out.printf("%.1f\n", (sum / count));
}
}
}``` ## URI Problem (Below the Secundary Diagonal) 1186 Solution in Java

URI Problem (Below the Secundary Diagonal) 1186:
Below the Secundary Diagonal is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

```import java.util.Scanner;

/**
* @Date : Oct 28, 2016
* @Time : 3:29:44 PM
*/
public class Uri1186 {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double m[][] = new double;
double sum = 0;
int count = 0;
String v = sc.next();
for (int i = 0; i < m.length; i++) {
for (int j = 0; j < m.length; j++) {
double x = sc.nextDouble();
m[i][j] = x;

if (j > (m.length - i - 1)) {
sum += x;
count++;
}
}
}
if (v.equals("S")) {
System.out.printf("%.1f\n", sum);
} else {
System.out.printf("%.1f\n", (sum / count));
}
}
}``` ## URI Problem (Above the Secundary Diagonal) 1185 Solution in Java

URI Problem (Above the Secundary Diagonal) 1185:
Above the Secundary Diagonal is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

```import java.util.Scanner;

/**
* @Date : Oct 28, 2016
* @Time : 3:23:06 PM
*/
public class Uri1185 {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double m[][] = new double;
double sum = 0;
int count = 0;
String v = sc.next();
for (int i = 0; i < m.length; i++) {
for (int j = 0; j < m.length; j++) {
double x = sc.nextDouble();
m[i][j] = x;

if (j < (m.length - i-1)) {
sum += x;
count++;
}
}
}
if (v.equals("S")) {
System.out.printf("%.1f\n", sum);
} else {
System.out.printf("%.1f\n", (sum / count));
}
}
}``` ## URI Problem (Below the Main Diagonal) 1184 Solution in Java

URI Problem (Below the Main Diagonal) 1184:
Below the Main Diagonal is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

```import java.util.Scanner;

/**
* @Date : Oct 28, 2016
* @Time : 3:14:38 PM
*/
public class Uri1184 {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double m[][] = new double;
double sum = 0;
int count = 0;
String v = sc.next();
for (int i = 0; i < m.length; i++) {
for (int j = 0; j < m.length; j++) {
double x = sc.nextDouble();
m[i][j] = x;
if (i > j) {
sum += x;
count++;
}
}
}
if (v.equals("S")) {
System.out.printf("%.1f\n", sum);
} else {
System.out.printf("%.1f\n", (sum / count));
}
}
}``` ## URI Problem (Above the Main Diagonal) 1183 Solution in Java

URI Problem (Above the Main Diagonal) 1183:
Above the Main Diagonal is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

```import java.util.Scanner;

/**
* @Date : Oct 28, 2016
* @Time : 2:51:24 PM
*/
public class Uri1183 {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double m[][] = new double;
double sum = 0;
int count = 0;
String v = sc.next();
for (int i = 0; i < m.length; i++) {
for (int j = 0; j < m.length; j++) {
double x = sc.nextDouble();
m[i][j] = x;
if (i < j) {
sum += x;
count++;
}
}
}
if (v.equals("S")) {
System.out.printf("%.1f\n", sum);
} else {
System.out.printf("%.1f\n", (sum / count));
}
}
}``` ## URI Problem (Column in Array) 1182 Solution in Java

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;

/**
* @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;
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));
}
}
}
}``` ## URI Problem (Line in Array) 1181 Solution in Java

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;

/**
* @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;
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));
}
}
}
}``` ## URI Problem (Lowest Number and Position) 1180 Solution in Java

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;

/**
* @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);
}
}
}``` ## URI Problem (Array Fill IV) 1179 Solution in Java

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;

/**
* @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;
int impar[] = new int;
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++;
}

}
}
}
}``` ## URI Problem (Sum of Consecutive Even Numbers) 1159 Solution in Java

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;

/**
* @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);
}
}
}
}``` ## URI Problem (Sum of Consecutive Odd Numbers III) 1158 Solution in Java

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;

/**
* @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);
}
}
}``` ## URI Problem (Divisors I) 1157 Solution in Java

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;

/**
* @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);
}
}
}
}``` ## URI Problem (S Sequence II) 1156 Solution in Java

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.

```/**
* @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);
}
}``` ## URI Problem (S Sequence) 1155 Solution in Java

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.

```/**
* @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);
}
}``` ## URI Problem (Ages) 1154 Solution in Java

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;

/**
* @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);
}
}``` ## URI Problem (Simple Factorial) 1153 Solution in Java

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.OutputStreamWriter;

/**
* @Date : Oct 21, 2016
* @Time : 10:08:20 PM
*/
public class Uri1153 {

public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
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);
}
}
}```