結果
| 問題 |
No.354 メルセンヌ素数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-04-01 22:24:51 |
| 言語 | Go (1.23.4) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 996 bytes |
| コンパイル時間 | 12,463 ms |
| コンパイル使用メモリ | 229,132 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-10 23:51:51 |
| 合計ジャッジ時間 | 13,083 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 13 |
ソースコード
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func main() {
sc.Split(bufio.ScanWords)
n := nextUint64()
fmt.Println(bitCount(n))
}
func bitCount(x uint64) uint64 {
x = (x & 0x5555555555555555) + ((x & 0xAAAAAAAAAAAAAAAA) >> 1)
x = (x & 0x3333333333333333) + ((x & 0xCCCCCCCCCCCCCCCC) >> 2)
x = (x & 0x0F0F0F0F0F0F0F0F) + ((x & 0xF0F0F0F0F0F0F0F0) >> 4)
x = (x & 0x00ff00ff00ff00ff) + ((x & 0xff00ff00ff00ff00) >> 8)
x = (x & 0x0000ffff0000ffff) + ((x & 0xffff0000ffff0000) >> 16)
x = (x & 0x00000000ffffffff) + ((x & 0xffffffff00000000) >> 32)
return x
}
func nextLine() string {
sc.Scan()
return sc.Text()
}
func nextInt() int {
i, _ := strconv.Atoi(nextLine())
return i
}
func nextInt64() int64 {
i, _ := strconv.ParseInt(nextLine(), 10, 64)
return i
}
func nextUint64() uint64 {
i, _ := strconv.ParseUint(nextLine(), 10, 64)
return i
}
func nextFloat() float64 {
f, _ := strconv.ParseFloat(nextLine(), 64)
return f
}