結果

問題 No.2087 基数の変換
ユーザー ripityripity
提出日時 2022-09-30 21:22:11
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 6,749 bytes
コンパイル時間 19,015 ms
コンパイル使用メモリ 442,332 KB
実行使用メモリ 50,724 KB
最終ジャッジ日時 2023-08-24 14:25:59
合計ジャッジ時間 32,974 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 265 ms
50,412 KB
testcase_01 AC 262 ms
50,544 KB
testcase_02 AC 264 ms
50,196 KB
testcase_03 AC 265 ms
50,088 KB
testcase_04 AC 276 ms
50,200 KB
testcase_05 AC 273 ms
50,184 KB
testcase_06 AC 267 ms
50,324 KB
testcase_07 AC 266 ms
50,236 KB
testcase_08 AC 263 ms
50,284 KB
testcase_09 AC 263 ms
50,516 KB
testcase_10 AC 265 ms
50,476 KB
testcase_11 AC 267 ms
50,252 KB
testcase_12 AC 265 ms
50,356 KB
testcase_13 AC 266 ms
50,336 KB
testcase_14 AC 265 ms
50,320 KB
testcase_15 AC 263 ms
50,280 KB
testcase_16 AC 264 ms
50,292 KB
testcase_17 AC 268 ms
50,264 KB
testcase_18 AC 263 ms
50,504 KB
testcase_19 AC 264 ms
50,192 KB
testcase_20 AC 268 ms
50,532 KB
testcase_21 AC 264 ms
50,340 KB
testcase_22 AC 265 ms
50,268 KB
testcase_23 AC 268 ms
50,252 KB
testcase_24 AC 266 ms
50,364 KB
testcase_25 AC 264 ms
50,320 KB
testcase_26 AC 265 ms
50,252 KB
testcase_27 AC 274 ms
50,724 KB
testcase_28 AC 266 ms
50,324 KB
testcase_29 AC 272 ms
50,400 KB
testcase_30 AC 273 ms
50,208 KB
testcase_31 AC 267 ms
50,332 KB
testcase_32 AC 264 ms
50,380 KB
testcase_33 AC 263 ms
50,336 KB
testcase_34 AC 270 ms
50,420 KB
testcase_35 AC 266 ms
50,408 KB
testcase_36 AC 265 ms
50,440 KB
testcase_37 AC 267 ms
50,180 KB
testcase_38 AC 263 ms
50,240 KB
testcase_39 AC 263 ms
50,396 KB
testcase_40 AC 268 ms
50,528 KB
testcase_41 AC 272 ms
50,316 KB
testcase_42 AC 262 ms
50,336 KB
testcase_43 AC 263 ms
50,096 KB
testcase_44 AC 266 ms
50,252 KB
testcase_45 AC 266 ms
50,488 KB
testcase_46 AC 266 ms
50,192 KB
testcase_47 AC 265 ms
50,208 KB
testcase_48 AC 265 ms
50,704 KB
testcase_49 AC 266 ms
50,492 KB
testcase_50 AC 274 ms
50,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:183:54: warning: 'toLong(): Long' is deprecated. Conversion of Char to Number is deprecated. Use Char.code property instead.
            cs[i] = modP(cs[i-1] + mul(pb[i], s[i-1].toLong()))
                                                     ^

ソースコード

diff #

import java.io.*
import java.util.*
import kotlin.math.*
import kotlin.random.Random

fun main() {
    
    // val T = nextInt()
    // repeat(T) {solve()}
    // pw.flush()
    
    solve()
    pw.flush()
    
}

fun solve() {
    
    val N = nextInt()
    val M = nextInt()
    
    pw.println(M.toString(N))
    
}

/* struct begin */

data class Cell(val r: Int, val c: Int)
data class Point(val x: Long, val y: Long)
data class Pii(val fi: Int, val se: Int)
data class Edge(val to: Int, val w: Long)

class SegmentTree(n: Int) {
    
    val INF = 1L shl 60
    val N = 1 shl intceil(log2(n.toDouble())+1.0)
    var a = LongArray(2*N) { INF }
    var b = LongArray(2*N) { -INF }
    
    fun update(idx: Int, x: Long) {
        
        var i = idx + N
        
        a[i] = x
        b[i] = x
        
        while( i > 1 ) {
            i = i shr 1
            val l = 2 * i
            val r = 2 * i + 1
            a[i] = min(a[l], a[r])
            b[i] = max(a[l], a[r])
        }
        
    }
    
    fun query1(L: Int, R: Int): Long {
        
        var l = L + N
        var r = R + N
        var res = INF
        
        while( l < r ) {
            if( (l and 1) == 1 ) { res = min(res, a[l]); l++ }
            if( (r and 1) == 1 ) { r--; res = min(res, a[r]) }
            l = l shr 1
            r = r shr 1
        }
        
        return res
        
    }
    
    fun query2(L: Int, R: Int): Long {
        
        var l = L + N
        var r = R + N
        var res = -INF
        
        while( l < r ) {
            if( (l and 1) == 1 ) { res = max(res, a[l]); l++ }
            if( (r and 1) == 1 ) { r--; res = max(res, a[r]) }
            l = l shr 1
            r = r shr 1
        }
        
        return res
        
    }
    
}

class BinaryIndexedTree(n: Int) {
    
    val N = n
    var a = Array<Long>(N+1) { 0L }
    
    fun sum(l: Int, r: Int): Long = sumSub(r-1)-sumSub(l-1)
    
    fun sumSub(i: Int): Long {
        
        var idx = i+1
        var res = 0L
        while( idx > 0 ) {
            res += a[idx]
            idx -= idx and (-idx)
        }
        
        return res
        
    }
    
    fun add(i: Int, x: Long) {
        
        var idx = i+1
        while( idx <= N ) {
            a[idx] += x
            idx += idx and (-idx)
        }
        
    }
    
}

class UnionFind(N: Int) {
    
    var parent = Array<Int>(N) {it}
    var rank = Array<Int>(N) {1}
    var size = Array<Int>(N) {1}
    
    fun root(x: Int): Int {
        
        if( parent[x] == x ) {
            return x
        }else {
            parent[x] = root(parent[x])
            return parent[x]
        }
        
    }
    
    fun unite(x: Int, y: Int) {
        
        val rx = root(x)
        val ry = root(y)
        if( rx == ry ) return
        
        if( rank[rx] > rank[ry] ) {
            parent[ry] = rx
            size[rx] += size[ry]
        }else {
            parent[rx] = ry
            size[ry] += size[rx]
            if( rank[rx] == rank[ry] ) rank[ry]++
        }
        
    }
    
    fun same(x: Int, y: Int): Boolean = (root(x) == root(y))
    fun getSize(x: Int): Int = size[root(x)]
    
}

class RollingHash(S: String) {
    
    val s = S
    val N = s.length
    val P = (1L shl 61) - 1
    val B = 565625656256562L
    val C = 2210565333882893047L
    val MASK30 = (1L shl 30) - 1
    val MASK31 = (1L shl 31) - 1
    
    var pb = LongArray(N+1) { 1L }
    var pc = LongArray(N+1) { 1L }
    var cs = LongArray(N+1) { 0L }
    
    fun init() {
        
        for( i in 1..N ) {
            pb[i] = mul(pb[i-1], B)
            pc[i] = mul(pc[i-1], C)
            cs[i] = modP(cs[i-1] + mul(pb[i], s[i-1].toLong()))
        }
        
    }
    
    fun hash(l: Int, r: Int): Long {
        
        return mul(cs[r] - cs[l] + P, pc[l])
        
    }
    
    fun mul(a: Long, b: Long): Long {
        
        val au = a shr 31
        val ad = a and MASK31
        val bu = b shr 31
        val bd = b and MASK31
        val m = au * bd + bu * ad
        val mu = m shr 30
        val md = m and MASK30
        
        return modP(2 * au * bu + mu + (md shl 31) + ad * bd)
        
    }
    
    fun modP(x: Long): Long {
        
        val xu = x shr 61
        val xd = x and P
        
        if( xu + xd >= P ) return (xu + xd - P)
        else return (xu + xd)
        
    }
    
}

/* struct end */

/* math begin */

fun intceil(x: Double) = ceil(x).toInt()
fun intfloor(x: Double) = floor(x).toInt()
fun gcd(x: Long, y: Long): Long {
    
    var a = max(abs(x), abs(y))
    var b = min(abs(x), abs(y))
    var r: Long
    
    do {
        r = a%b
        a = b
        b = r
    }while( r > 0 )
    
    return a
    
}

fun modpow(X: Long, T: Long, P: Long = 9223372036854775807L): Long {
    
    var x = X
    var t = T
    
    if( t == 0L ) {
        return 1L
    }else {
        var res = 1L
        while( t > 0 ) {
            if( t%2L == 1L ) {
                res *= x
                res %= P
                t -= 1L
            }
            x *= x
            x %= P
            t /= 2
        }
        return res%P
    }
    
}

/* math end */

/* utility begin */

fun cumulativeSum(a: LongArray): LongArray {
    
    val N = a.size
    var s = LongArray(N+1) { 0L }
    
    for( i in 1..N ) {
        s[i] = s[i-1]+a[i-1]
    }
    
    return s
    
}

fun rlowerBound(a: LongArray, x: Long): Int {
    
    val N = a.size
    var high = N-1
    var low = 0
    var mid: Int
    
    while( low < high ) {
        mid = (high+low+1)/2
        if( a[mid] > x ) high = mid-1
        else low = high
    }
    
    return high
    
}

fun lowerBound(a: IntArray, x: Int): Int {
    
    val N = a.size
    var high = N-1
    var low = 0
    var mid: Int
    
    while( low < high ) {
        mid = (high+low)/2
        if( a[mid] < x ) low = mid+1
        else high = mid
    }
    
    return low
    
}

fun permInv(p: IntArray): IntArray {
    
    val N = p.size
    var res = IntArray(N) { -1 }
    
    for( i in 0 until N ) {
        res[p[i]] = i
    }
    
    return res
    
}

/* utility end */

/* I/O begin */

var st = StringTokenizer("")
val br = System.`in`.bufferedReader()
val pw = PrintWriter(System.out, false)

fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextLine() = br.readLine()!!
fun nextDouble() = next().toDouble()
fun nextStrarr(n: Int) = Array<String>(n) { next() }
fun nextIntarr(n: Int, dec: Int = 0) = IntArray(n) { nextInt()-dec }
fun nextLongarr(n: Int, dec: Long = 0L) = LongArray(n) { nextLong()-dec }

fun next(): String {
    
    while( !st.hasMoreTokens() ) st = StringTokenizer(br.readLine()!!)
    return st.nextToken()
    
}

/* I/O end */
0