結果
問題 | No.965 門松列が嫌い |
ユーザー | Mpikumin |
提出日時 | 2020-02-19 19:38:43 |
言語 | Nim (2.0.2) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 3,354 bytes |
コンパイル時間 | 4,172 ms |
コンパイル使用メモリ | 60,824 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-08 15:21:51 |
合計ジャッジ時間 | 5,003 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 1 ms
5,248 KB |
testcase_05 | AC | 1 ms
5,248 KB |
testcase_06 | AC | 1 ms
5,248 KB |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 1 ms
5,248 KB |
testcase_09 | AC | 2 ms
5,248 KB |
ソースコード
type Bool* = bool type Int* = int type Lint* = int64 type Char* = char type String* = string template exit* = quit 0 template make*[T]( body :untyped ) :T = block: proc f() :T = body f() proc less*[T1,T2]( x :T1; y :T2 ) :Bool = x < y proc more*[T1,T2]( x :T1; y :T2 ) :Bool = x > y proc add*[T1,T2]( x :T1; y :T2 ) :T1 = x + y proc mul*[T1,T2]( x :T1; y :T2 ) :T1 = x * y proc `max=`*[T]( x :var T; y :T ) = if x < y: x = y proc `min=`*[T]( x :var T; y :T ) = if x > y: x = y iterator items*( n :Int ) :Int = for i in 0 ..< n: yield i proc contain*[T]( t :iterator:T; e :T) :Bool = for x in t: if e == x: return true return false proc read*( T :typedesc ) :T = proc getchar() :char {.header:"stdio.h",importc:"getchar_unlocked".} when T is Char: result = getchar() discard getchar() when T is String: result = "" while true: var c = getchar() if [' ', '\10', '\255'].contain c: break result.add c when T is (Int or Lint): var sign = 1 c = getchar() if c == '-': sign = -1 c = getchar() while '0' <= c and c <= '9': result *= 10 result += c.int - '0'.int c = getchar() result *= sign when T is tuple: for r in result.fields: r = r.type.read proc write*[T]( x :T ) = echo x iterator read*[T]( n :Int ) :Int = for _ in n: yield T.read iterator filter*[T]( t :iterator:T; p:proc(x:T):Bool ) :T = for x in t: if x.p: yield x type Vect*[T] = seq[T] proc vect*[T]( t :iterator:T ) :Vect[T] = for x in t: result &= x proc vect*[T]( t :iterator:T; n :Int ) :Vect[T] = result.newSeq[T] n var i = 0 for x in t: result[i] = x i.inc type Mint*[M :static[Int]] = distinct Int const Mod7* = 1000000007 const Mod9* = 1000000009 type Mint7* = Mint[Mod7] type Mint9* = Mint[Mod9] proc mint*[M :static[Int]]( n :Int ) :Mint[M] = result = Mint[M] n mod M if result.int < 0: result = Mint[M] result.int + M proc `$`*( m :Mint ) :string = $m.int proc `+`*[I;M:static[Int]]( m:Mint[M]; n:I) :Mint[M] = mint[M] m.int + n.int proc `-`*[I;M:static[Int]]( m:Mint[M]; n:I) :Mint[M] = mint[M] m.int - n.int proc `*`*[I;M:static[Int]]( m:Mint[M]; n:I) :Mint[M] = mint[M] m.int * n.int proc `/`*[I;M:static[Int]]( m:Mint[M]; n:I) :Mint[M] = var a = n.int b = M u = 1 v = 0 while b > 0: var t = a div b a -= t * b u -= t * v swap( a, b ) swap( u, v ) return m * u proc `+=`*[I;M:static[Int]]( m :var Mint[M]; n :I ) = m = m + n proc `-=`*[I;M:static[Int]]( m :var Mint[M]; n :I ) = m = m - n proc `*=`*[I;M:static[Int]]( m :var Mint[M]; n :I ) = m = m * n proc `/=`*[I;M:static[Int]]( m :var Mint[M]; n :I ) = m = m / n proc fact*[I]( n :Int ) :I = var memo {.global.} :Vect[I] = @[1.I] if n >= memo.len: let m = memo.len memo.setLen n + 1 for i in m..n: memo[i] = memo[i-1] * i return memo[n] let (a,b,c) = (int,int,int).read [abs(a-b),abs(b-c),abs(c-a)].min.write #