Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 574b2d6

Browse files
atcoder 169
1 parent 8fe872c commit 574b2d6

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

‎atcoder/169/Multiplication.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import java.io.*;
2+
public class Multiplication{
3+
public static void main(String[] args)throws IOException{
4+
final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
5+
int a=Integer.parseInt(br.readLine());
6+
int b=Integer.parseInt(br.readLine());
7+
System.out.println(a*b);
8+
}
9+
}

‎atcoder/169/Multiplication2.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import java.util.Scanner;
2+
import java.util.Arrays;
3+
public class Multiplication2{
4+
public static void main(String[] args){
5+
final Scanner cin = new Scanner(System.in);
6+
int n = cin.nextInt();
7+
long[] arr=new long[n];
8+
for(int i=0;i<n;i++){
9+
arr[i]=cin.nextLong();
10+
}
11+
Arrays.parallelSort(arr);
12+
if(arr[0]==0){
13+
System.out.print(0);
14+
return;
15+
}
16+
long mul=1;
17+
for(long a:arr){
18+
if(mul*1.0*a >(long)1e18 || mul<=0){
19+
System.out.print(-1);
20+
System.exit(0);
21+
}
22+
mul=mul*a;
23+
//System.out.print(mul+" ");
24+
}
25+
//System.out.println();
26+
System.out.print(mul>(long)1e18?-1:mul);
27+
}
28+
}
29+

‎atcoder/169/Multiplication3.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import java.util.Scanner;
2+
import java.math.*;
3+
public class Multiplication3{
4+
public static void main(String[] args){
5+
final Scanner cin=new Scanner(System.in);
6+
long a=cin.nextLong();
7+
double b=cin.nextDouble();
8+
long k=(long)Math.round(b*100);
9+
long mul=(a*k);
10+
System.out.print(mul/100);
11+
}
12+
}

‎atcoder/169/mul.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import java.util.Scanner;
2+
import java.math.BigInteger;
3+
4+
public class mul{
5+
public static void main(String[] args){
6+
final Scanner cin = new Scanner(System.in);
7+
BigInteger a=cin.nextBigInteger();
8+
BigInteger b=cin.nextBigInteger();
9+
BigInteger c=BigInteger.ONE;
10+
c=a.multiply(b);
11+
System.out.println(c);
12+
}
13+
}
14+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /