Task: | Onnenluku |
Sender: | |
Submission time: | 2015-09-13 12:44:19 +0300 |
Language: | Java |
Status: | READY |
Result: | 33 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | ACCEPTED | 33 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.20 s | 1 | details |
#2 | ACCEPTED | 0.20 s | 1 | details |
#3 | WRONG ANSWER | 0.20 s | 1 | details |
#4 | ACCEPTED | 0.20 s | 1 | details |
#5 | ACCEPTED | 0.21 s | 1 | details |
#6 | ACCEPTED | 0.98 s | 2 | details |
#7 | ACCEPTED | 0.97 s | 2 | details |
#8 | ACCEPTED | 0.97 s | 2 | details |
#9 | ACCEPTED | 0.98 s | 2 | details |
#10 | ACCEPTED | 0.95 s | 2 | details |
#11 | TIME LIMIT EXCEEDED | -- | 3 | details |
#12 | TIME LIMIT EXCEEDED | -- | 3 | details |
#13 | TIME LIMIT EXCEEDED | -- | 3 | details |
#14 | TIME LIMIT EXCEEDED | -- | 3 | details |
#15 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
import java.math.BigInteger; import java.util.Scanner; public class Onnenluku { static long löytynyt = 0; static BigInteger min, max; public static void main(String[] args) { String temp; Scanner input = new Scanner(System.in); min = input.nextBigInteger(); max = input.nextBigInteger(); final int maxpituus = max.toString().length(); for (int k1 = 1 ; k1 <= 9; k1++){ for (int k2 = k1+1; k2 <= 9; k2++){ silmukka(Integer.toString(k1),maxpituus, Integer.toString(k1), Integer.toString(k2)); silmukka(Integer.toString(k2),maxpituus, Integer.toString(k1), Integer.toString(k2)); } } System.out.println(löytynyt); } static BigInteger vertailuluku; static void silmukka(String a, int n, String k1, String k2) { if (n>0) { if (a.contains(k1) && a.contains(k2)){ vertailuluku = new BigInteger(a); if (vertailuluku.compareTo(min)==1 && vertailuluku.compareTo(max)==-1){ löytynyt++; } } silmukka(a+k1, n-1, k1, k2); silmukka(a+k2, n-1, k1, k2); } } }
Test details
Test 1
Group: 1
Verdict: ACCEPTED
input |
---|
2157 93337 |
correct output |
---|
1421 |
user output |
---|
1421 |
Test 2
Group: 1
Verdict: ACCEPTED
input |
---|
4875 95124 |
correct output |
---|
1278 |
user output |
---|
1278 |
Test 3
Group: 1
Verdict: WRONG ANSWER
input |
---|
5577 96352 |
correct output |
---|
1245 |
user output |
---|
1244 |
Test 4
Group: 1
Verdict: ACCEPTED
input |
---|
8362 92950 |
correct output |
---|
1076 |
user output |
---|
1076 |
Test 5
Group: 1
Verdict: ACCEPTED
input |
---|
5658 96660 |
correct output |
---|
1238 |
user output |
---|
1238 |
Test 6
Group: 2
Verdict: ACCEPTED
input |
---|
51312303535233 994542403556353 |
correct output |
---|
1453976 |
user output |
---|
1453976 |
Test 7
Group: 2
Verdict: ACCEPTED
input |
---|
25636920452341 934558290712847 |
correct output |
---|
1544072 |
user output |
---|
1544072 |
Test 8
Group: 2
Verdict: ACCEPTED
input |
---|
7917952071965 985207415843573 |
correct output |
---|
1763176 |
user output |
---|
1763176 |
Test 9
Group: 2
Verdict: ACCEPTED
input |
---|
48991581181227 907034837225965 |
correct output |
---|
1380248 |
user output |
---|
1380248 |
Test 10
Group: 2
Verdict: ACCEPTED
input |
---|
47968703305149 924246001328437 |
correct output |
---|
1396632 |
user output |
---|
1396632 |
Test 11
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
292953755324413237753216241025... |
correct output |
---|
53286731528535944 |
user output |
---|
(empty) |
Test 12
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
373990979330820426927419348165... |
correct output |
---|
51580289482227600 |
user output |
---|
(empty) |
Test 13
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
701417326319476057561825658890... |
correct output |
---|
42924933948374952 |
user output |
---|
(empty) |
Test 14
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
177202883511434557056457305647... |
correct output |
---|
54500592365600640 |
user output |
---|
(empty) |
Test 15
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
977665117437419620152569155919... |
correct output |
---|
38562071809359800 |
user output |
---|
(empty) |