-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathp040.java
More file actions
40 lines (32 loc) · 786 Bytes
/
p040.java
File metadata and controls
40 lines (32 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
*
* @author gouravrusiya
*
*/
public class p040 {
public static void main(String[] args) {
// TODO Auto-generated method stub
long startTime = System.currentTimeMillis();
StringBuffer str = new StringBuffer("");
String s = "";
long mul = 1L;
long x = 0L;
for(int i=1;i<=1000000;i++)
{
str=str.append(i);
//System.out.println(str);
if(i==1 || i==10 || i==100 || i==1000 || i==10000 || i==100000 || i==1000000)
{
s = "" + str.charAt(i-1);
//System.out.println(s);
x = Long.parseLong(s);
//System.out.println(x);
mul = mul*x;
//System.out.println(mul);
}
}
System.out.println(mul);
long endTime = System.currentTimeMillis();
//System.out.println("Took "+(endTime - startTime) + " ms");
}
}