結果
問題 |
No.1243 約数加算
|
ユーザー |
![]() |
提出日時 | 2020-10-02 22:48:34 |
言語 | Go (1.23.4) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,144 bytes |
コンパイル時間 | 11,761 ms |
コンパイル使用メモリ | 238,132 KB |
実行使用メモリ | 13,756 KB |
最終ジャッジ日時 | 2024-07-17 22:37:37 |
合計ジャッジ時間 | 15,449 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 2 TLE * 1 -- * 6 |
ソースコード
package main import ( "bufio" "fmt" "os" ) func main() { defer writer.Flush() T := ReadInt() for t := 0; t < T; t++ { A, B := ReadInt(), ReadInt() solve(A, B) } } func solve(A, B int) { ans := make([]int, 0) for A < B { max := B - A ok := false for i := 1; i <= B/2; i++ { j := B / i if j <= max && B%i == 0 { ans = append(ans, j) B -= j ok = true break } } if !ok { j := 1 ans = append(ans, j) B -= j } } Println(len(ans)) for i := 0; i < len(ans); i++ { if i > 0 { Printf(" ") } Printf("%d", ans[len(ans)-i-1]) } Println() } var reader = bufio.NewReader(os.Stdin) func Scan(a ...interface{}) { if _, err := fmt.Fscan(reader, a...); err != nil { panic(err) } } func ReadInt() (i int) { Scan(&i); return } func ReadString() (s string) { Scan(&s); return } func ReadInts(n int) (a []int) { for i := 0; i < n; i++ { a = append(a, ReadInt()) } return } var writer = bufio.NewWriter(os.Stdout) func Printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) } func Println(a ...interface{}) { fmt.Fprintln(writer, a...) }