結果
問題 | No.420 mod2漸化式 |
ユーザー |
![]() |
提出日時 | 2020-05-26 15:02:03 |
言語 | Go (1.23.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,944 bytes |
コンパイル時間 | 14,266 ms |
コンパイル使用メモリ | 229,580 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-13 02:43:27 |
合計ジャッジ時間 | 12,601 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 21 WA * 14 |
ソースコード
package mainimport ("bufio""fmt""os""strconv")func getScanner(fp *os.File) *bufio.Scanner {scanner := bufio.NewScanner(fp)scanner.Split(bufio.ScanWords)scanner.Buffer(make([]byte, 1000005), 1000005)return scanner}func getNextString(scanner *bufio.Scanner) string {scanner.Scan()return scanner.Text()}func getNextInt(scanner *bufio.Scanner) int {i, _ := strconv.Atoi(getNextString(scanner))return i}func getNextInt64(scanner *bufio.Scanner) int64 {i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)return i}func getNextUint64(scanner *bufio.Scanner) uint64 {i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)return i}func getNextFloat64(scanner *bufio.Scanner) float64 {i, _ := strconv.ParseFloat(getNextString(scanner), 64)return i}func main() {fp := os.Stdinwfp := os.Stdoutcnt := 0if os.Getenv("MASPY") == "ますピ" {fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))cnt = 5}if os.Getenv("MASPYPY") == "ますピッピ" {wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))}scanner := getScanner(fp)writer := bufio.NewWriter(wfp)solve(scanner, writer)for i := 0; i < cnt; i++ {fmt.Fprintln(writer, "-----------------------------------")solve(scanner, writer)}writer.Flush()}func solve(scanner *bufio.Scanner, writer *bufio.Writer) {x := getNextInt(scanner)if x == 0 {fmt.Fprintf(writer, "%d %d\n", 1, 0)return}if x > 31 {fmt.Fprintf(writer, "%d %d\n", 0, 0)return}if x > 16 {x = 31 - x}var ans, c, cc int64c = 1cc = 1for i := 0; i < x; i++ {c *= int64(31 - i)c /= int64(i + 1)if i == 0 {continue}cc *= int64(31 - i)cc /= int64(i)}ans = (1<<uint(31) - 1) * ccfmt.Fprintf(writer, "%d %d\n", c, ans)}func nextCombination(bits int64) int64 {lowest1 := bits & -bitsnewbits := bits + lowest1newbits |= ((bits & ^newbits) / lowest1) >> 1return newbits}