結果

問題 No.18 うーさー暗号
コンテスト
ユーザー gogotea
提出日時 2015-03-26 13:39:18
言語 Go
(1.26.1)
コンパイル:
env GOCACHE=/tmp go build _filename_
実行:
./Main
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 556 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 11,226 ms
コンパイル使用メモリ 276,848 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2026-03-28 20:38:57
合計ジャッジ時間 11,095 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	S := nextLine()
	fmt.Println(woosarCipher(S))
}

func woosarCipher(plain string) string {
	cipher := make([]rune, len(plain))
	for i, c := range plain {
		cipher[i] = rotate(c, i+1)
	}
	return string(cipher)
}

func rotate(c rune, n int) rune {
	ret := c - rune(n%26)
	if ret < 'A' {
		return ret + 26
	} else {
		return ret
	}
}

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Split(bufio.ScanLines)
	sc.Scan()
	if nil != sc.Err() {
		panic(sc.Err())
	}
	return sc.Text()
}
0