結果
問題 | No.970 数列変換マシン |
ユーザー | Mpikumin |
提出日時 | 2020-02-19 20:19:35 |
言語 | Nim (2.0.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,580 bytes |
コンパイル時間 | 4,271 ms |
コンパイル使用メモリ | 61,520 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-08 17:12:58 |
合計ジャッジ時間 | 6,690 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
ソースコード
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 type Vect*[T] = seq[T] proc vect*[T]( n :Int ) :Vect[T] = newSeq[T](result, n) 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 = vect[T] n for (i, x) in t: result[i] = x 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 proc read*( T :typedesc; n :Int ) :Vect[T] = result = vect[T] n for i in n: result[i] = T.read iterator filter*[T]( t :iterator:T; p:proc(x:T):Bool ) :T = for x in t: if x.p: yield x proc sum*[T]( t :Vect[T] ) :T = for x in t: result += x 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] = result = m result /= 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 `/=`*[I;M:static[Int]]( m :var Mint[M]; n :I ) = 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 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] ####### main ########### let N = Int.read B = Int.read N S = B.sum for b in B: write S - (N - 1) * b #