結果

問題 No.18 うーさー暗号
ユーザー poginpogin
提出日時 2016-03-22 03:24:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,617 bytes
コンパイル時間 4,409 ms
コンパイル使用メモリ 82,824 KB
実行使用メモリ 58,240 KB
最終ジャッジ日時 2024-04-08 21:43:37
合計ジャッジ時間 6,453 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
57,928 KB
testcase_01 AC 135 ms
57,676 KB
testcase_02 AC 142 ms
57,716 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

//@see http://yukicoder.me/problems/59

public class No18 {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		System.out.println(ursarDecoding(s));
//		sample();
		
	}
	private static void sample() {
		String text = "abc";
		String data1 = ceaserEncoding(text, 3);
		System.out.println(data1);
		System.out.println(ceaserDecoding(data1, 3));
		System.out.println(ursarDecoding("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
		System.out.println(ursarDecoding("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"));
	}
	public static String ursarDecoding(String text) {
		String data = "";
		for (int i = 0; i < text.length(); i++) {

			int divi = i % 26;
			int substRet = char2int(text.charAt(divi), divi);
			int ret;
			if (substRet <= 0) {
				ret = "Z".charAt(0) + substRet;
			} else {
				ret = ((text.charAt(divi) - divi) - 1);
			}

			data = data + String.valueOf(Character.toString((char)ret));
		}
		return data;
	}
	
	private static int char2int(char c, int i) {
		return ((c - 'A') - i);
	}
	
	public static String ceaserEncoding (String text, int no) {
		String data1 = "";
		for (int i = 0; i < text.length(); i++) {
			data1 = data1 + String.valueOf((char)(text.charAt(i) + no));
		}
		return data1;
	}
	public static String ceaserDecoding (String text, int no) {
		String data1 = "";
		for (int i = 0; i < text.length(); i++) {
			data1 = data1 + String.valueOf((char)(text.charAt(i) - no));
		}
		return data1;
		
	}


}
0