- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCode.java
More file actions
Latest commit
46 lines (39 loc) · 997 Bytes
/
Copy pathCode.java
File metadata and controls
46 lines (39 loc) · 997 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
41
42
43
44
45
46
importjava.io.BufferedReader;
importjava.io.IOException;
importjava.io.InputStreamReader;
publicclassCode {
publicstaticvoidmain(String[] args) {
try {
newFindPasswordAttempts();
}
catch(IOExceptione) {
e.printStackTrace();
}
}
}
classFindPasswordAttempts{
privateStringcodeChars;
privateStringtruthCode;
privatelongresult;
publicFindPasswordAttempts() throwsIOException{
BufferedReaderbr = newBufferedReader(newInputStreamReader(System.in));
codeChars = br.readLine();
truthCode = br.readLine();
result = 0;
FindPassword();
result = CompressionNum(result);
System.out.println(result+"");
}
publicvoidFindPassword() {
longpow = 1;
for(inti = truthCode.length()-1; i >=0; i--) {
result += (pow*(codeChars.indexOf(truthCode.charAt(i))+1));
result = CompressionNum(result);
pow = pow * codeChars.length();
pow = CompressionNum(pow);
}
}
publiclongCompressionNum(longnum) {
returnnum%=900528;
}
}