ZOJ-1799
来源:互联网 发布:设有一个二维数组a m n 编辑:程序博客网 时间:2024/06/05 17:28
这题其实挺简单。。还做了好久,逻辑思维不大行啊,要多练练
import java.util.Scanner;public class Main{public static void main(String[] args){Scanner sc = new Scanner(System.in);while (true){String key = sc.nextLine().trim();if ("THEEND".equals(key))break;String ciphertext = sc.nextLine().trim();int rows = ciphertext.length() / key.length();char[][] plain = new char[rows][key.length()];int[] orders = getOrder(key);for (int i = 0; i < key.length(); i++){for (int j = 0; j < rows; j++){plain[j][i] = ciphertext.charAt(rows * (orders[i] - 1) + j);}}for (char[] cc : plain){for (char ccc : cc)System.out.print(ccc);}System.out.println();}}static int[] getOrder(String s){char[] chars = s.toCharArray();int[] orders = new int[chars.length];for (int i = 0; i < chars.length; i++){int order = 1;for (int j = 0; j < chars.length; j++){if (j < i){if (chars[i] >= chars[j])order++;}else{if (chars[i] > chars[j])order++;}}orders[i] = order;}return orders;}}
0 0
- ZOJ-1799
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- python科学计算五:sklearn学习
- ZK高级特性:Style定制与客户端集成
- 列表分区
- CenOS下mysql5.6修改字符编码,解决sql语句中带有中文,会乱码问题
- 最长有效括号的长度--英雄会
- ZOJ-1799
- HttpClient的超时用法小记
- Jquery实现模态窗口—simplemodal
- Android菜单详解(三)——SubMenu和IconMenu
- Android回调的使用方式
- 【cocos2D-x学习】17.手势识别
- ios KVO
- 非常实用。。。c++函数sort函数运用(排序运用)
- .NET中出现 混合模式程序集是针对“v2.0.50727”版的运行时生成的,在没有配置其他信息的情况下,无法在 4.0 运行时中加载该程序集