Submission Detail

305 / 305 test cases passed.
Status:

Accepted

Runtime: 2 ms
Memory Usage: 41.2 MB
Submitted: 0 minutes ago
loading
Runtime Error Message:
Last executed input:
Input:
Output:
Expected:

Accepted Solutions Runtime Distribution

0
2
4
6
8
10
12
14
16
18
20
20
40
60
80
100
java
You are here!
Your runtime beats 8.07 % of java submissions.
Runtime (ms)
Distribution (%)

0
2
4
6
8
10
12
14
16
18
20
50
100
Zoom area by dragging across this chart

Accepted Solutions Memory Distribution

39800
40000
40200
40400
40600
40800
41000
41200
41400
41600
2.5
5.0
7.5
10.0
12.5
java
You are here!
Your memory usage beats 32.68 % of java submissions.
Memory (KB)
Distribution (%)

39800
40000
40200
40400
40600
40800
41000
41200
41400
41600
5
10
Zoom area by dragging across this chart

Invite friends to challenge Pow(x, n)


Submitted Code: 0 minutes ago

Language: java

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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
class Solution {
public double myPow(double x, int n) {
double power = 1;
double ten = 0;
double hundred = 0;
double thousand = 0;
double ten_thousand = 0;
double hundred_thousand = 0;
double million = 0;
long i = 1;
long last_i = 1;
long refined_n = n;
while (i <= Math.abs(refined_n)) {
// million check
if (i % 1000000 == 0 && i > 1000000) {
power *= million;
if (Math.abs(refined_n) >= (i+1000000)) {
last_i = i;
i += 1000000;
} else {
last_i = i;
i += 100;
}
continue;
}
// hundred thousand check
if (i % 100000 == 0 && i > 100000) {
if (last_i % 100000 == 0)
power *= hundred_thousand;
else if (last_i % 10000 == 0)
power *= ten_thousand;
else if (last_i % 1000 == 0)
power *= thousand;
else if (last_i % 100 == 0)
power *= hundred;
else if (last_i % 10 == 0)
power *= ten;
else
power *= x;
if (Math.abs(refined_n) >= (i+100000)) {
last_i = i;
i += 100000;
}
else {
last_i = i;
i += 10;
}
if (i == 1000000)
million = power*hundred_thousand;
continue;
}
// ten thousand check
if (i % 10000 == 0 && i > 10000) {
if (last_i % 10000 == 0)
power *= ten_thousand;
else if (last_i % 1000 == 0)
power *= thousand;
else if (last_i % 100 == 0)
power *= hundred;
else if (last_i % 10 == 0)
power *= ten;
else
power *= x;
if (Math.abs(refined_n) >= (i+10000)) {
last_i = i;
i += 10000;
}
else {
last_i = i;
i += 1;
}
if (i == 100000)
hundred_thousand = power*ten_thousand;
continue;
}
// thousand check
if (i % 1000 == 0 && i > 1000) {
if (last_i % 1000 == 0)
power *= thousand;
else if (last_i % 100 == 0)
power *= hundred;
else if (last_i % 10 == 0)
power *= ten;
else
power *= x;
if (Math.abs(refined_n) >= (i+1000)) {
last_i = i;
i += 1000;
}
else {
last_i = i;
i += 1;
}
if (i == 10000)
ten_thousand = power*thousand;
continue;
}
// hundred check
if (i % 100 == 0 && i > 100) {
if (last_i % 100 == 0)
power *= hundred;
else if (last_i % 10 == 0)
power *= ten;
else
power *= x;
if (Math.abs(refined_n) >= (i+100)) {
last_i = i;
i += 100;
}
else {
last_i = i;
i += 1;
}
if (i == 1000)
thousand = power*hundred;
continue;
}
// ten check
if (i % 10 == 0 && i > 10) {
if (last_i % 10 == 0)
power *= ten;
else
power *= x;
if (Math.abs(refined_n) >= (i+10)) {
last_i = i;
i += 10;
}
else {
last_i = i;
i += 1;
}
if (i == 100)
hundred = power*ten;
continue;
}
// one
power *= x;
if (i == 100000) {
million = power;
System.out.println("set: "+million);
}
if (i == 100000)
hundred_thousand = power;
if (i == 10000)
ten_thousand = power;
if (i == 1000)
thousand = power;
if (i == 100) {
hundred = power;
}
if (i == 10) {
ten = power;
}
last_i = i;
i++;
}
if (n < 0)
power = 1/power;
return power;
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX