結果

問題 No.756 チャンパーノウン定数 (1)
コンテスト
ユーザー ciel
提出日時 2018-12-06 12:10:45
言語 Go
(1.26.1)
コンパイル:
env GOCACHE=/tmp go build _filename_
実行:
./Main
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 634 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 13,020 ms
コンパイル使用メモリ 280,320 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-04 09:34:27
合計ジャッジ時間 13,786 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

//usr/bin/env go run $0 $@;exit
package main
import(
	"fmt"
	"os"
	"text/scanner"
	"strconv"
)

var sin scanner.Scanner
func scanint() int64{
	tok:=sin.Scan()
	if tok==scanner.EOF {return -1}
	ret,_ := strconv.ParseInt(sin.TokenText(),10,64)
	return ret
}

func main(){
	sin.Init(os.Stdin)
	var starting,bse,n,digits,expbase,x,num int64
	starting=1
	bse=10
	for {
		n=scanint()
		if n==-1 {break}
		n+=starting-2
		digits=1
		expbase=1
		x=bse-1
		for x<=n {
			n-=x
			digits+=1
			expbase*=bse
			x=digits*expbase*(bse-1)
		}
		num=expbase+n/digits
		d:=digits-1-n%digits
		for ;d>0;d-- {
			num/=bse
		}
		fmt.Println(num%bse)
	}
}
0