<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    emu in blogjava

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      171 隨筆 :: 103 文章 :: 1052 評(píng)論 :: 2 Trackbacks


    Problem Statement
    ????
    A square matrix is a grid of NxN numbers. For example, the following is a 3x3 matrix:
     4 3 5
     2 4 5
     0 1 9
    One way to represent a matrix of numbers, each of which is between 0 and 9 inclusive, is as a row-major String. To generate the String, simply concatenate all of the elements from the first row followed by the second row and so on, without any spaces. For example, the above matrix would be represented as "435245019".  You will be given a square matrix as a row-major String. Your task is to convert it into a String[], where each element represents one row of the original matrix. Element i of the String[] represents row i of the matrix. You should not include any spaces in your return. Hence, for the above String, you would return {"435","245","019"}. If the input does not represent a square matrix because the number of characters is not a perfect square, return an empty String[], {}.
    Definition
    ????
    Class:
    MatrixTool
    Method:
    convert
    Parameters:
    String
    Returns:
    String[]
    Method signature:
    String[] convert(String s)
    (be sure your method is public)
    ????

    Constraints
    -
    s will contain between 1 and 50 digits, inclusive.
    Examples
    0)

    ????
    "435245019"
    Returns: {"435", "245", "019" }
    The example above.
    1)

    ????
    "9"
    Returns: {"9" }

    2)

    ????
    "0123456789"
    Returns: { }
    This input has 10 digits, and 10 is not a perfect square.
    3)

    ????
    "3357002966366183191503444273807479559869883303524"
    Returns: {"3357002", "9663661", "8319150", "3444273", "8074795", "5986988", "3303524" }

    This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.



    局搞笑的題目。這次中國錦標(biāo)賽的模擬題比起上次東亞的差的太遠(yuǎn)了。解一個(gè)吧:

    public class MatrixTool {
        
    public String[] convert(String s){
            
    int l = s.length();
            
    int sq = new Double(Math.sqrt(l)).intValue();
            
    if(sq*sq!=l)return new String[]{};
            String[] result 
    = new String[sq];
            
    for(int i=0;i<sq;i++)
                result[i]
    =s.substring(i*sq,(i+1)*sq);
            
    return result;
        }

        
    public static void main(String[] args){
            String[] s;
            s 
    = new MatrixTool().convert("435245019");
            System.out.println(java.util.Arrays.asList(s));
            s 
    = new MatrixTool().convert("0123456789");
            System.out.println(java.util.Arrays.asList(s));
            s 
    = new MatrixTool().convert("3357002966366183191503444273807479559869883303524");
            System.out.println(java.util.Arrays.asList(s));
        }

    }
    posted on 2005-12-01 16:33 emu 閱讀(1071) 評(píng)論(1)  編輯  收藏 所屬分類: google編程大賽模擬題及入圍賽真題

    評(píng)論

    # re: google中國編程挑戰(zhàn)賽模擬題 -- MatrixTool (500分) 2005-12-10 00:20 小飛俠
    public class MatrixTool{
    public String[] convert(String s) {
    int slen, col;
    slen = s.length();
    col = (int)Math.sqrt(slen);
    if ( slen % col != 0) {
    String[] ret = new String[0];
    return ret;
    }

    String[] ret = new String[col];
    for (int i = 0; i < col; i++) {
    ret[i] = s.substring(i*col, (i+1)*col);
    }

    return ret;
    }
    }   回復(fù)  更多評(píng)論
      

    主站蜘蛛池模板: 成人免费区一区二区三区| 久久精品国产亚洲Aⅴ香蕉| 东方aⅴ免费观看久久av| 亚洲中文无码mv| 精品日韩亚洲AV无码一区二区三区| 亚洲国产精品狼友中文久久久 | 永久免费毛片手机版在线看| 久久综合国产乱子伦精品免费| xxxxxx日本处大片免费看| 亚洲精品无码mⅴ在线观看| 色噜噜综合亚洲av中文无码| 亚洲色中文字幕无码AV| 亚洲精品A在线观看| 国产又大又粗又硬又长免费| 免费可以在线看A∨网站| 国产成人免费午夜在线观看| 99久久精品免费精品国产| 国内精品久久久久影院免费| 国产成人精品免费大全| 人妻仑刮八A级毛片免费看| 337p日本欧洲亚洲大胆人人| 亚洲国产成人精品无码区花野真一 | 久久久久久亚洲av成人无码国产 | 国产va在线观看免费| 成人免费777777被爆出| 日韩毛片一区视频免费| 无套内谢孕妇毛片免费看看| 国产成人不卡亚洲精品91| 久久精品国产亚洲av品善| 亚洲国产午夜精品理论片在线播放| 亚洲av乱码一区二区三区香蕉| 亚洲国产模特在线播放| 亚洲六月丁香六月婷婷蜜芽| 亚洲伊人久久大香线蕉在观| 亚洲av日韩av综合| 一区二区亚洲精品精华液| 亚洲国产乱码最新视频| 亚洲国产精品成人AV在线| 亚洲va中文字幕| 免费一级毛片在线播放视频免费观看永久 | 亚洲国产精品成人精品无码区|