結果
| 問題 |
No.18 うーさー暗号
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-22 03:24:45 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,617 bytes |
| コンパイル時間 | 3,347 ms |
| コンパイル使用メモリ | 79,476 KB |
| 実行使用メモリ | 41,944 KB |
| 最終ジャッジ日時 | 2024-10-01 12:42:05 |
| 合計ジャッジ時間 | 5,388 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 10 |
ソースコード
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;
}
}