結果
問題 |
No.2016 Countdown Divisors
|
ユーザー |
|
提出日時 | 2022-07-23 13:49:41 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 894 bytes |
コンパイル時間 | 13,589 ms |
コンパイル使用メモリ | 227,528 KB |
実行使用メモリ | 7,168 KB |
最終ジャッジ日時 | 2024-07-05 01:47:42 |
合計ジャッジ時間 | 15,396 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 19 |
ソースコード
package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) var out = bufio.NewWriter(os.Stdout) func solve(t int, n []int) []int { memo := map[int]bool{1: true, 3: true, 4: true, 5: true, 7: true, 8: true} var ans []int for i := 0; i < t; i++ { if n[i] <= 8 { if _, contains := memo[n[i]]; contains { ans = append(ans, 1) } else { ans = append(ans, 2) } } else { ans = append(ans, 2) } } return ans } func main() { buf := make([]byte, 1024*1024) sc.Buffer(buf, bufio.MaxScanTokenSize) sc.Split(bufio.ScanWords) t := nextInt() var n []int for i := 0; i < t; i++ { n = append(n, nextInt()) } ans := solve(t, n) PrintVertically(ans) } func nextInt() int { sc.Scan() i, _ := strconv.Atoi(sc.Text()) return i } func PrintVertically(x []int) { defer out.Flush() for _, v := range x { fmt.Fprintln(out, v) } }