-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1157.kt
40 lines (34 loc) · 869 Bytes
/
1157.kt
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
import java.io.BufferedReader
import java.io.BufferedWriter
import java.io.InputStreamReader
import java.io.OutputStreamWriter
import java.util.*
import kotlin.math.pow
fun main() {
val bw = BufferedWriter(OutputStreamWriter(System.out))
val br = BufferedReader(InputStreamReader(System.`in`))
val s = br.readLine().uppercase(Locale.getDefault())
val alpha = Array<Int>(26, { 0 })
for (i in 0..s.lastIndex) {
alpha[s[i].code - 65]++
}
var max = 0
var maxA = 0
for (i in 0..25) {
if (alpha[i] >= max) {
max = alpha[i]
maxA = i
}
}
var cnt = 0
for(i in 0..25){
if(max==alpha[i]){
cnt++
}
}
if(cnt==1)
bw.write("${(maxA+65).toChar()}\n")
else
bw.write("?\n")
bw.flush()
}