项目欧拉17错误答案

时间:2013-12-24 06:08:08

标签: java

我在解决问题17时遇到了问题。

如果数字1到5用文字写出:一,二,三,四,五,那么总共有3 + 3 + 5 + 4 + 4 = 19个字母。

如果所有1到1000(一千)的数字都用文字写出来,会用多少个字母?

注意:不要计算空格或连字符。例如,342(三百四十二)包含23个字母,115(一百一十五)包含20个字母 字母。在写出数字时使用“和”符合英国的用法。

我的节目输出是17722但是PE说这是一个错误的答案。我究竟做错了什么?这是我的代码。

public class NumberLetter {
    public static void main(String[] args) {
        String[] firstNormals = {"one","two","three","four","five","six","seven","eight","nine"};
        String[] secondNormals = {"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
        String[] thirdNormals = {"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};
        String[] fourthNormals = {"oneHundred","twoHundred","threeHundred","fourHundred","fiveHundred","sixHundred","sevenHundred","eightHundred","nineHundred"};
        String fifthNormal = "oneThousand";
        long first = 0;
        long second = 0;
        long third = 0;
        long fourth = 0;
        for (int i = 0; i < firstNormals.length; i++) {
            first += firstNormals[i].length();
        }
        for (int i = 0; i < secondNormals.length; i++) {
            second += secondNormals[i].length();
        }
        for (int i = 0; i < thirdNormals.length; i++) {
            third += thirdNormals[i].length();
        }
        for (int i = 0; i < fourthNormals.length; i++) {
            fourth += fourthNormals[i].length()+third+second+first;
        }
        for (String thirdCharacters : thirdNormals) {
            for (String firstCharacters : firstNormals) {
                third += thirdCharacters.length()+firstCharacters.length();
            }
        }
        for (String fourthCharacters : fourthNormals) {
            for (String thirdCharacters : thirdNormals) {
                for (String firstCharacters : firstNormals) {
                    fourth += fourthCharacters.length()+3+thirdCharacters.length()+firstCharacters.length();
                }
            }
        }
        long sum = first+second+third+fourth+fifthNormal.length();
        System.out.println(sum);
    }
}

我怎样才能提高效率呢?提前谢谢。

4 个答案:

答案 0 :(得分:1)

这里有一个很好的解释:

http://www.mathblog.dk/project-euler-17-letters-in-the-numbers-1-1000/

您可以使用那里提供的逻辑来提供更优雅,更有效的解决方案。

关于您的具体解决方案,我不确定第四个循环正在做什么。看起来你正试图添加100,200,300,......,以及101,102,103,......,201,202,203 ......,以及110,111,112 ,...,210,211,212,......,以及120,130,140,......,220,230,240 ......如果是这样,那么你不算全部他们。该循环仅运行9次。

答案 1 :(得分:1)

使用Map的解决方案:

import java.util.HashMap;
import java.util.Map;

public class P17 {

    static final int N = 1000;
    static Map<Integer, Integer> numbers = new HashMap<>();
    static final int HUNDRED_LENGTH = "hundred".length();
    static final int AND_LENGTH = "and".length();

    public static void main(String[] args) {

        addNumber(1, "one");
        addNumber(2, "two");
        addNumber(3, "three");
        addNumber(4, "four");
        addNumber(5, "five");
        addNumber(6, "six");
        addNumber(7, "seven");
        addNumber(8, "eight");
        addNumber(9, "nine");
        addNumber(10, "ten");
        addNumber(11, "eleven");
        addNumber(12, "twelve");
        addNumber(13, "thirteen");
        addNumber(14, "fourteen");
        addNumber(15, "fifteen");
        addNumber(16, "sixteen");
        addNumber(17, "seventeen");
        addNumber(18, "eighteen");
        addNumber(19, "nineteen");
        addNumber(20, "twenty");
        addNumber(30, "thirty");
        addNumber(40, "forty");
        addNumber(50, "fifty");
        addNumber(60, "sixty");
        addNumber(70, "seventy");
        addNumber(80, "eighty");
        addNumber(90, "ninety");
        addNumber(1000, "oneThousand");

        int sum = 0;
        // x01 - x99 -> 10 times
        for ( int i = 1 ; i < 20 ; i++ ) {
            sum+=numbers.get(i);
        }       
        for ( int i = 20 ; i <= 99 ; i++ ) {
            int u = i%10;
            sum+=numbers.get((i/10)*10);
            if ( u > 0 ) {
                sum+=numbers.get(u);
            }
        }
        sum*=10;

        /* hundred */
        for ( int i = 100 ; i < N ; i++ ) {
            int h = i/100;
            int r = i%100;
            sum+=numbers.get(h);
            sum+=HUNDRED_LENGTH;
            if ( r > 0 ) {
                sum+=AND_LENGTH;
            }
        }
        sum+=numbers.get(N);

        System.out.println(sum);
    }

    static void addNumber(int number, String numberAsString) {
        numbers.put(number, numberAsString.length());
    }

}

答案 2 :(得分:0)

你的for循环非常混乱,尝试使用基于方法的方法来执行常见任务。

由于您要计算每个String数组中的字母数,您可以这样做:

    long first = lengthOf(firstNormals);
    long second = lengthOf(secondNormals);
    long third = lengthOf(thirdNormals);
    //...rest of your code 



    private long lengthOf(String[] s){ //returns total number of alphabets in array
        return Arrays.asList(s).toString().replaceAll( "\\W", "" ).length();
    }

答案 3 :(得分:0)

代码需要一些逻辑来确定您正在查看的数字

一种粗略的方式,最多只能做1000 ..

public static void main(String[] args) {

    String[] firstNormals = {"one","two","three","four","five","six","seven","eight","nine"};
    String[] secondNormals = {"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
    String[] thirdNormals = {"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};
    String[] fourthNormals = {"oneHundred","twoHundred","threeHundred","fourHundred","fiveHundred","sixHundred","sevenHundred","eightHundred","nineHundred"};
    String[] fifthNormal = {"oneThousand"};

    List<String> numberStringList = new ArrayList<String>();

    for (Integer i = 1; i <= 1000; i++) {
       int length = i.toString().length();

       if(length == 1){
           int digitIndex = Integer.parseInt(  new StringBuilder().append(i.toString().toCharArray()[0]).toString() );
           numberStringList.add(firstNormals[digitIndex-1]);
       } else if(length == 2){

           int tenIndex = Integer.parseInt(  new StringBuilder().append(i.toString().toCharArray()[0]).toString() );
           int digitIndex = Integer.parseInt(  new StringBuilder().append(i.toString().toCharArray()[1]).toString() );
           //10, 11 ..
           if(tenIndex == 1){
               numberStringList.add(secondNormals[digitIndex]);
           } else { //20, 30
               numberStringList.add(thirdNormals[tenIndex-2]);
               if(digitIndex != 0){
                   numberStringList.add(firstNormals[digitIndex-1]);
               }
           }

       } else if(length == 3){
          int hundredIndex = Integer.parseInt(  new StringBuilder().append(i.toString().toCharArray()[0]).toString() );
          numberStringList.add(fourthNormals[hundredIndex-1]);

          int tenIndex = Integer.parseInt(  new StringBuilder().append(i.toString().toCharArray()[1]).toString() );
          int digitIndex = Integer.parseInt(  new StringBuilder().append(i.toString().toCharArray()[2]).toString() );

          if(tenIndex == 1){
              numberStringList.add(secondNormals[digitIndex]);  
          } else if(tenIndex != 0){
              numberStringList.add(thirdNormals[tenIndex-2]);
          }

          if(digitIndex != 0 && tenIndex != 1){
              numberStringList.add(firstNormals[digitIndex-1]);  
          }
       } else if(length > 3){
          int thousandIndex = Integer.parseInt(  new StringBuilder().append(i.toString().toCharArray()[0]).toString() );
          numberStringList.add(fifthNormal[thousandIndex-1]);
       }

    }   
}

那将输出

  one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty, twenty, one, twenty, two, twenty, three, twenty, four, twenty, five, twenty, six, twenty, seven, twenty, eight, twenty, nine, thirty, thirty, one, thirty, two, thirty, three, thirty, four, thirty, five, thirty, six, thirty, seven, thirty, eight, thirty, nine, forty, forty, one, forty, two, forty, three, forty, four, forty, five, forty, six, forty, seven, forty, eight, forty, nine, fifty, fifty, one, fifty, two, fifty, three, fifty, four, fifty, five, fifty, six, fifty, seven, fifty, eight, fifty, nine, sixty, sixty, one, sixty, two, sixty, three, sixty, four, sixty, five, sixty, six, sixty, seven, sixty, eight, sixty, nine, seventy, seventy, one, seventy, two, seventy, three, seventy, four, seventy, five, seventy, six, seventy, seven, seventy, eight, seventy, nine, eighty, eighty, one, eighty, two, eighty, three, eighty, four, eighty, five, eighty, six, eighty, seven, eighty, eight, eighty, nine, ninety, ninety, one, ninety, two, ninety, three, ninety, four, ninety, five, ninety, six, ninety, seven, ninety, eight, ninety, nine, oneHundred, oneHundred, one, oneHundred, two, oneHundred, three, oneHundred, four, oneHundred, five, oneHundred, six, oneHundred, seven, oneHundred, eight, oneHundred, nine, oneHundred, ten, oneHundred, eleven, oneHundred, twelve, oneHundred, thirteen, oneHundred, fourteen, oneHundred, fifteen, oneHundred, sixteen, oneHundred, seventeen, oneHundred, eighteen, oneHundred, nineteen, oneHundred, twenty, oneHundred, twenty, one, oneHundred, twenty, two, oneHundred, twenty, three, oneHundred, twenty, four, oneHundred, twenty, five, oneHundred, twenty, six, oneHundred, twenty, seven, oneHundred, twenty, eight, oneHundred, twenty, nine, oneHundred, thirty, oneHundred, thirty, one, oneHundred, thirty, two, oneHundred, thirty, three, oneHundred, thirty, four, oneHundred, thirty, five, oneHundred, thirty, six, oneHundred, thirty, seven, oneHundred, thirty, eight, oneHundred, thirty, nine, oneHundred, forty, oneHundred, forty, one, oneHundred, forty, two, oneHundred, forty, three, oneHundred, forty, four, oneHundred, forty, five, oneHundred, forty, six, oneHundred, forty, seven, oneHundred, forty, eight, oneHundred, forty, nine, oneHundred, fifty, oneHundred, fifty, one, oneHundred, fifty, two, oneHundred, fifty, three, oneHundred, fifty, four, oneHundred, fifty, five, oneHundred, fifty, six, oneHundred, fifty, seven, oneHundred, fifty, eight, oneHundred, fifty, nine, oneHundred, sixty, oneHundred, sixty, one, oneHundred, sixty, two, oneHundred, sixty, three, oneHundred, sixty, four, oneHundred, sixty, five, oneHundred, sixty, six, oneHundred, sixty, seven, oneHundred, sixty, eight, oneHundred, sixty, nine, oneHundred, seventy, oneHundred, seventy, one, oneHundred, seventy, two, oneHundred, seventy, three, oneHundred, seventy, four, oneHundred, seventy, five, oneHundred, seventy, six, oneHundred, seventy, seven, oneHundred, seventy, eight, oneHundred, seventy, nine, oneHundred, eighty, oneHundred, eighty, one, oneHundred, eighty, two, oneHundred, eighty, three, oneHundred, eighty, four, oneHundred, eighty, five, oneHundred, eighty, six, oneHundred, eighty, seven, oneHundred, eighty, eight, oneHundred, eighty, nine, oneHundred, ninety, oneHundred, ninety, one, oneHundred, ninety, two, oneHundred, ninety, three, oneHundred, ninety, four, oneHundred, ninety, five, oneHundred, ninety, six, oneHundred, ninety, seven, oneHundred, ninety, eight, oneHundred, ninety, nine, twoHundred, twoHundred, one, twoHundred, two, twoHundred, three, twoHundred, four, twoHundred, five, twoHundred, six, twoHundred, seven, twoHundred, eight, twoHundred, nine, twoHundred, ten, twoHundred, eleven, twoHundred, twelve, twoHundred, thirteen, twoHundred, fourteen, twoHundred, fifteen, twoHundred, sixteen, twoHundred, seventeen, twoHundred, eighteen, twoHundred, nineteen, twoHundred, twenty, twoHundred, twenty, one, twoHundred, twenty, two, twoHundred, twenty, three, twoHundred, twenty, four, twoHundred, twenty, five, twoHundred, twenty, six, twoHundred, twenty, seven, twoHundred, twenty, eight, twoHundred, twenty, nine, twoHundred, thirty, twoHundred, thirty, one, twoHundred, thirty, two, twoHundred, thirty, three, twoHundred, thirty, four, twoHundred, thirty, five, twoHundred, thirty, six, twoHundred, thirty, seven, twoHundred, thirty, eight, twoHundred, thirty, nine, twoHundred, forty, twoHundred, forty, one, twoHundred, forty, two, twoHundred, forty, three, twoHundred, forty, four, twoHundred, forty, five, twoHundred, forty, six, twoHundred, forty, seven, twoHundred, forty, eight, twoHundred, forty, nine, twoHundred, fifty, twoHundred, fifty, one, twoHundred, fifty, two, twoHundred, fifty, three, twoHundred, fifty, four, twoHundred, fifty, five, twoHundred, fifty, six, twoHundred, fifty, seven, twoHundred, fifty, eight, twoHundred, fifty, nine, twoHundred, sixty, twoHundred, sixty, one, twoHundred, sixty, two, twoHundred, sixty, three, twoHundred, sixty, four, twoHundred, sixty, five, twoHundred, sixty, six, twoHundred, sixty, seven, twoHundred, sixty, eight, twoHundred, sixty, nine, twoHundred, seventy, twoHundred, seventy, one, twoHundred, seventy, two, twoHundred, seventy, three, twoHundred, seventy, four, twoHundred, seventy, five, twoHundred, seventy, six, twoHundred, seventy, seven, twoHundred, seventy, eight, twoHundred, seventy, nine, twoHundred, eighty, twoHundred, eighty, one, twoHundred, eighty, two, twoHundred, eighty, three, twoHundred, eighty, four, twoHundred, eighty, five, twoHundred, eighty, six, twoHundred, eighty, seven, twoHundred, eighty, eight, twoHundred, eighty, nine, twoHundred, ninety, twoHundred, ninety, one, twoHundred, ninety, two, twoHundred, ninety, three, twoHundred, ninety, four, twoHundred, ninety, five, twoHundred, ninety, six, twoHundred, ninety, seven, twoHundred, ninety, eight, twoHundred, ninety, nine, threeHundred, threeHundred, one, threeHundred, two, threeHundred, three, threeHundred, four, threeHundred, five, threeHundred, six, threeHundred, seven, threeHundred, eight, threeHundred, nine, threeHundred, ten, threeHundred, eleven, threeHundred, twelve, threeHundred, thirteen, threeHundred, fourteen, threeHundred, fifteen, threeHundred, sixteen, threeHundred, seventeen, threeHundred, eighteen, threeHundred, nineteen, threeHundred, twenty, threeHundred, twenty, one, threeHundred, twenty, two, threeHundred, twenty, three, threeHundred, twenty, four, threeHundred, twenty, five, threeHundred, twenty, six, threeHundred, twenty, seven, threeHundred, twenty, eight, threeHundred, twenty, nine, threeHundred, thirty, threeHundred, thirty, one, threeHundred, thirty, two, threeHundred, thirty, three, threeHundred, thirty, four, threeHundred, thirty, five, threeHundred, thirty, six, threeHundred, thirty, seven, threeHundred, thirty, eight, threeHundred, thirty, nine, threeHundred, forty, threeHundred, forty, one, threeHundred, forty, two, threeHundred, forty, three, threeHundred, forty, four, threeHundred, forty, five, threeHundred, forty, six, threeHundred, forty, seven, threeHundred, forty, eight, threeHundred, forty, nine, threeHundred, fifty, threeHundred, fifty, one, threeHundred, fifty, two, threeHundred, fifty, three, threeHundred, fifty, four, threeHundred, fifty, five, threeHundred, fifty, six, threeHundred, fifty, seven, threeHundred, fifty, eight, threeHundred, fifty, nine, threeHundred, sixty, threeHundred, sixty, one, threeHundred, sixty, two, threeHundred, sixty, three, threeHundred, sixty, four, threeHundred, sixty, five, threeHundred, sixty, six, threeHundred, sixty, seven, threeHundred, sixty, eight, threeHundred, sixty, nine, threeHundred, seventy, threeHundred, seventy, one, threeHundred, seventy, two, threeHundred, seventy, three, threeHundred, seventy, four, threeHundred, seventy, five, threeHundred, seventy, six, threeHundred, seventy, seven, threeHundred, seventy, eight, threeHundred, seventy, nine, threeHundred, eighty, threeHundred, eighty, one, threeHundred, eighty, two, threeHundred, eighty, three, threeHundred, eighty, four, threeHundred, eighty, five, threeHundred, eighty, six, threeHundred, eighty, seven, threeHundred, eighty, eight, threeHundred, eighty, nine, threeHundred, ninety, threeHundred, ninety, one, threeHundred, ninety, two, threeHundred, ninety, three, threeHundred, ninety, four, threeHundred, ninety, five, threeHundred, ninety, six, threeHundred, ninety, seven, threeHundred, ninety, eight, threeHundred, ninety, nine, fourHundred, fourHundred, one, fourHundred, two, fourHundred, three, fourHundred, four, fourHundred, five, fourHundred, six, fourHundred, seven, fourHundred, eight, fourHundred, nine, fourHundred, ten, fourHundred, eleven, fourHundred, twelve, fourHundred, thirteen, fourHundred, fourteen, fourHundred, fifteen, fourHundred, sixteen, fourHundred, seventeen, fourHundred, eighteen, fourHundred, nineteen, fourHundred, twenty, fourHundred, twenty, one, fourHundred, twenty, two, fourHundred, twenty, three, fourHundred, twenty, four, fourHundred, twenty, five, fourHundred, twenty, six, fourHundred, twenty, seven, fourHundred, twenty, eight, fourHundred, twenty, nine, fourHundred, thirty, fourHundred, thirty, one, fourHundred, thirty, two, fourHundred, thirty, three, fourHundred, thirty, four, fourHundred, thirty, five, fourHundred, thirty, six, fourHundred, thirty, seven, fourHundred, thirty, eight, fourHundred, thirty, nine, fourHundred, forty, fourHundred, forty, one, fourHundred, forty, two, fourHundred, forty, three, fourHundred, forty, four, fourHundred, forty, five, fourHundred, forty, six, fourHundred, forty, seven, fourHundred, forty, eight, fourHundred, forty, nine, fourHundred, fifty, fourHundred, fifty, one, fourHundred, fifty, two, fourHundred, fifty, three, fourHundred, fifty, four, fourHundred, fifty, five, fourHundred, fifty, six, fourHundred, fifty, seven, fourHundred, fifty, eight, fourHundred, fifty, nine, fourHundred, sixty, fourHundred, sixty, one, fourHundred, sixty, two, fourHundred, sixty, three, fourHundred, sixty, four, fourHundred, sixty, five, fourHundred, sixty, six, fourHundred, sixty, seven, fourHundred, sixty, eight, fourHundred, sixty, nine, fourHundred, seventy, fourHundred, seventy, one, fourHundred, seventy, two, fourHundred, seventy, three, fourHundred, seventy, four, fourHundred, seventy, five, fourHundred, seventy, six, fourHundred, seventy, seven, fourHundred, seventy, eight, fourHundred, seventy, nine, fourHundred, eighty, fourHundred, eighty, one, fourHundred, eighty, two, fourHundred, eighty, three, fourHundred, eighty, four, fourHundred, eighty, five, fourHundred, eighty, six, fourHundred, eighty, seven, fourHundred, eighty, eight, fourHundred, eighty, nine, fourHundred, ninety, fourHundred, ninety, one, fourHundred, ninety, two, fourHundred, ninety, three, fourHundred, ninety, four, fourHundred, ninety, five, fourHundred, ninety, six, fourHundred, ninety, seven, fourHundred, ninety, eight, fourHundred, ninety, nine, fiveHundred, fiveHundred, one, fiveHundred, two, fiveHundred, three, fiveHundred, four, fiveHundred, five, fiveHundred, six, fiveHundred, seven, fiveHundred, eight, fiveHundred, nine, fiveHundred, ten, fiveHundred, eleven, fiveHundred, twelve, fiveHundred, thirteen, fiveHundred, fourteen, fiveHundred, fifteen, fiveHundred, sixteen, fiveHundred, seventeen, fiveHundred, eighteen, fiveHundred, nineteen, fiveHundred, twenty, fiveHundred, twenty, one, fiveHundred, twenty, two, fiveHundred, twenty, three, fiveHundred, twenty, four, fiveHundred, twenty, five, fiveHundred, twenty, six, fiveHundred, twenty, seven, fiveHundred, twenty, eight, fiveHundred, twenty, nine, fiveHundred, thirty, fiveHundred, thirty, one, fiveHundred, thirty, two, fiveHundred, thirty, three, fiveHundred, thirty, four, fiveHundred, thirty, five, fiveHundred, thirty, six, fiveHundred, thirty, seven, fiveHundred, thirty, eight, fiveHundred, thirty, nine, fiveHundred, forty, fiveHundred, forty, one, fiveHundred, forty, two, fiveHundred, forty, three, fiveHundred, forty, four, fiveHundred, forty, five, fiveHundred, forty, six, fiveHundred, forty, seven, fiveHundred, forty, eight, fiveHundred, forty, nine, fiveHundred, fifty, fiveHundred, fifty, one, fiveHundred, fifty, two, fiveHundred, fifty, three, fiveHundred, fifty, four, fiveHundred, fifty, five, fiveHundred, fifty, six, fiveHundred, fifty, seven, fiveHundred, fifty, eight, fiveHundred, fifty, nine, fiveHundred, sixty, fiveHundred, sixty, one, fiveHundred, sixty, two, fiveHundred, sixty, three, fiveHundred, sixty, four, fiveHundred, sixty, five, fiveHundred, sixty, six, fiveHundred, sixty, seven, fiveHundred, sixty, eight, fiveHundred, sixty, nine, fiveHundred, seventy, fiveHundred, seventy, one, fiveHundred, seventy, two, fiveHundred, seventy, three, fiveHundred, seventy, four, fiveHundred, seventy, five, fiveHundred, seventy, six, fiveHundred, seventy, seven, fiveHundred, seventy, eight, fiveHundred, seventy, nine, fiveHundred, eighty, fiveHundred, eighty, one, fiveHundred, eighty, two, fiveHundred, eighty, three, fiveHundred, eighty, four, fiveHundred, eighty, five, fiveHundred, eighty, six, fiveHundred, eighty, seven, fiveHundred, eighty, eight, fiveHundred, eighty, nine, fiveHundred, ninety, fiveHundred, ninety, one, fiveHundred, ninety, two, fiveHundred, ninety, three, fiveHundred, ninety, four, fiveHundred, ninety, five, fiveHundred, ninety, six, fiveHundred, ninety, seven, fiveHundred, ninety, eight, fiveHundred, ninety, nine, sixHundred, sixHundred, one, sixHundred, two, sixHundred, three, sixHundred, four, sixHundred, five, sixHundred, six, sixHundred, seven, sixHundred, eight, sixHundred, nine, sixHundred, ten, sixHundred, eleven, sixHundred, twelve, sixHundred, thirteen, sixHundred, fourteen, sixHundred, fifteen, sixHundred, sixteen, sixHundred, seventeen, sixHundred, eighteen, sixHundred, nineteen, sixHundred, twenty, sixHundred, twenty, one, sixHundred, twenty, two, sixHundred, twenty, three, sixHundred, twenty, four, sixHundred, twenty, five, sixHundred, twenty, six, sixHundred, twenty, seven, sixHundred, twenty, eight, sixHundred, twenty, nine, sixHundred, thirty, sixHundred, thirty, one, sixHundred, thirty, two, sixHundred, thirty, three, sixHundred, thirty, four, sixHundred, thirty, five, sixHundred, thirty, six, sixHundred, thirty, seven, sixHundred, thirty, eight, sixHundred, thirty, nine, sixHundred, forty, sixHundred, forty, one, sixHundred, forty, two, sixHundred, forty, three, sixHundred, forty, four, sixHundred, forty, five, sixHundred, forty, six, sixHundred, forty, seven, sixHundred, forty, eight, sixHundred, forty, nine, sixHundred, fifty, sixHundred, fifty, one, sixHundred, fifty, two, sixHundred, fifty, three, sixHundred, fifty, four, sixHundred, fifty, five, sixHundred, fifty, six, sixHundred, fifty, seven, sixHundred, fifty, eight, sixHundred, fifty, nine, sixHundred, sixty, sixHundred, sixty, one, sixHundred, sixty, two, sixHundred, sixty, three, sixHundred, sixty, four, sixHundred, sixty, five, sixHundred, sixty, six, sixHundred, sixty, seven, sixHundred, sixty, eight, sixHundred, sixty, nine, sixHundred, seventy, sixHundred, seventy, one, sixHundred, seventy, two, sixHundred, seventy, three, sixHundred, seventy, four, sixHundred, seventy, five, sixHundred, seventy, six, sixHundred, seventy, seven, sixHundred, seventy, eight, sixHundred, seventy, nine, sixHundred, eighty, sixHundred, eighty, one, sixHundred, eighty, two, sixHundred, eighty, three, sixHundred, eighty, four, sixHundred, eighty, five, sixHundred, eighty, six, sixHundred, eighty, seven, sixHundred, eighty, eight, sixHundred, eighty, nine, sixHundred, ninety, sixHundred, ninety, one, sixHundred, ninety, two, sixHundred, ninety, three, sixHundred, ninety, four, sixHundred, ninety, five, sixHundred, ninety, six, sixHundred, ninety, seven, sixHundred, ninety, eight, sixHundred, ninety, nine, sevenHundred, sevenHundred, one, sevenHundred, two, sevenHundred, three, sevenHundred, four, sevenHundred, five, sevenHundred, six, sevenHundred, seven, sevenHundred, eight, sevenHundred, nine, sevenHundred, ten, sevenHundred, eleven, sevenHundred, twelve, sevenHundred, thirteen, sevenHundred, fourteen, sevenHundred, fifteen, sevenHundred, sixteen, sevenHundred, seventeen, sevenHundred, eighteen, sevenHundred, nineteen, sevenHundred, twenty, sevenHundred, twenty, one, sevenHundred, twenty, two, sevenHundred, twenty, three, sevenHundred, twenty, four, sevenHundred, twenty, five, sevenHundred, twenty, six, sevenHundred, twenty, seven, sevenHundred, twenty, eight, sevenHundred, twenty, nine, sevenHundred, thirty, sevenHundred, thirty, one, sevenHundred, thirty, two, sevenHundred, thirty, three, sevenHundred, thirty, four, sevenHundred, thirty, five, sevenHundred, thirty, six, sevenHundred, thirty, seven, sevenHundred, thirty, eight, sevenHundred, thirty, nine, sevenHundred, forty, sevenHundred, forty, one, sevenHundred, forty, two, sevenHundred, forty, three, sevenHundred, forty, four, sevenHundred, forty, five, sevenHundred, forty, six, sevenHundred, forty, seven, sevenHundred, forty, eight, sevenHundred, forty, nine, sevenHundred, fifty, sevenHundred, fifty, one, sevenHundred, fifty, two, sevenHundred, fifty, three, sevenHundred, fifty, four, sevenHundred, fifty, five, sevenHundred, fifty, six, sevenHundred, fifty, seven, sevenHundred, fifty, eight, sevenHundred, fifty, nine, sevenHundred, sixty, sevenHundred, sixty, one, sevenHundred, sixty, two, sevenHundred, sixty, three, sevenHundred, sixty, four, sevenHundred, sixty, five, sevenHundred, sixty, six, sevenHundred, sixty, seven, sevenHundred, sixty, eight, sevenHundred, sixty, nine, sevenHundred, seventy, sevenHundred, seventy, one, sevenHundred, seventy, two, sevenHundred, seventy, three, sevenHundred, seventy, four, sevenHundred, seventy, five, sevenHundred, seventy, six, sevenHundred, seventy, seven, sevenHundred, seventy, eight, sevenHundred, seventy, nine, sevenHundred, eighty, sevenHundred, eighty, one, sevenHundred, eighty, two, sevenHundred, eighty, three, sevenHundred, eighty, four, sevenHundred, eighty, five, sevenHundred, eighty, six, sevenHundred, eighty, seven, sevenHundred, eighty, eight, sevenHundred, eighty, nine, sevenHundred, ninety, sevenHundred, ninety, one, sevenHundred, ninety, two, sevenHundred, ninety, three, sevenHundred, ninety, four, sevenHundred, ninety, five, sevenHundred, ninety, six, sevenHundred, ninety, seven, sevenHundred, ninety, eight, sevenHundred, ninety, nine, eightHundred, eightHundred, one, eightHundred, two, eightHundred, three, eightHundred, four, eightHundred, five, eightHundred, six, eightHundred, seven, eightHundred, eight, eightHundred, nine, eightHundred, ten, eightHundred, eleven, eightHundred, twelve, eightHundred, thirteen, eightHundred, fourteen, eightHundred, fifteen, eightHundred, sixteen, eightHundred, seventeen, eightHundred, eighteen, eightHundred, nineteen, eightHundred, twenty, eightHundred, twenty, one, eightHundred, twenty, two, eightHundred, twenty, three, eightHundred, twenty, four, eightHundred, twenty, five, eightHundred, twenty, six, eightHundred, twenty, seven, eightHundred, twenty, eight, eightHundred, twenty, nine, eightHundred, thirty, eightHundred, thirty, one, eightHundred, thirty, two, eightHundred, thirty, three, eightHundred, thirty, four, eightHundred, thirty, five, eightHundred, thirty, six, eightHundred, thirty, seven, eightHundred, thirty, eight, eightHundred, thirty, nine, eightHundred, forty, eightHundred, forty, one, eightHundred, forty, two, eightHundred, forty, three, eightHundred, forty, four, eightHundred, forty, five, eightHundred, forty, six, eightHundred, forty, seven, eightHundred, forty, eight, eightHundred, forty, nine, eightHundred, fifty, eightHundred, fifty, one, eightHundred, fifty, two, eightHundred, fifty, three, eightHundred, fifty, four, eightHundred, fifty, five, eightHundred, fifty, six, eightHundred, fifty, seven, eightHundred, fifty, eight, eightHundred, fifty, nine, eightHundred, sixty, eightHundred, sixty, one, eightHundred, sixty, two, eightHundred, sixty, three, eightHundred, sixty, four, eightHundred, sixty, five, eightHundred, sixty, six, eightHundred, sixty, seven, eightHundred, sixty, eight, eightHundred, sixty, nine, eightHundred, seventy, eightHundred, seventy, one, eightHundred, seventy, two, eightHundred, seventy, three, eightHundred, seventy, four, eightHundred, seventy, five, eightHundred, seventy, six, eightHundred, seventy, seven, eightHundred, seventy, eight, eightHundred, seventy, nine, eightHundred, eighty, eightHundred, eighty, one, eightHundred, eighty, two, eightHundred, eighty, three, eightHundred, eighty, four, eightHundred, eighty, five, eightHundred, eighty, six, eightHundred, eighty, seven, eightHundred, eighty, eight, eightHundred, eighty, nine, eightHundred, ninety, eightHundred, ninety, one, eightHundred, ninety, two, eightHundred, ninety, three, eightHundred, ninety, four, eightHundred, ninety, five, eightHundred, ninety, six, eightHundred, ninety, seven, eightHundred, ninety, eight, eightHundred, ninety, nine, nineHundred, nineHundred, one, nineHundred, two, nineHundred, three, nineHundred, four, nineHundred, five, nineHundred, six, nineHundred, seven, nineHundred, eight, nineHundred, nine, nineHundred, ten, nineHundred, eleven, nineHundred, twelve, nineHundred, thirteen, nineHundred, fourteen, nineHundred, fifteen, nineHundred, sixteen, nineHundred, seventeen, nineHundred, eighteen, nineHundred, nineteen, nineHundred, twenty, nineHundred, twenty, one, nineHundred, twenty, two, nineHundred, twenty, three, nineHundred, twenty, four, nineHundred, twenty, five, nineHundred, twenty, six, nineHundred, twenty, seven, nineHundred, twenty, eight, nineHundred, twenty, nine, nineHundred, thirty, nineHundred, thirty, one, nineHundred, thirty, two, nineHundred, thirty, three, nineHundred, thirty, four, nineHundred, thirty, five, nineHundred, thirty, six, nineHundred, thirty, seven, nineHundred, thirty, eight, nineHundred, thirty, nine, nineHundred, forty, nineHundred, forty, one, nineHundred, forty, two, nineHundred, forty, three, nineHundred, forty, four, nineHundred, forty, five, nineHundred, forty, six, nineHundred, forty, seven, nineHundred, forty, eight, nineHundred, forty, nine, nineHundred, fifty, nineHundred, fifty, one, nineHundred, fifty, two, nineHundred, fifty, three, nineHundred, fifty, four, nineHundred, fifty, five, nineHundred, fifty, six, nineHundred, fifty, seven, nineHundred, fifty, eight, nineHundred, fifty, nine, nineHundred, sixty, nineHundred, sixty, one, nineHundred, sixty, two, nineHundred, sixty, three, nineHundred, sixty, four, nineHundred, sixty, five, nineHundred, sixty, six, nineHundred, sixty, seven, nineHundred, sixty, eight, nineHundred, sixty, nine, nineHundred, seventy, nineHundred, seventy, one, nineHundred, seventy, two, nineHundred, seventy, three, nineHundred, seventy, four, nineHundred, seventy, five, nineHundred, seventy, six, nineHundred, seventy, seven, nineHundred, seventy, eight, nineHundred, seventy, nine, nineHundred, eighty, nineHundred, eighty, one, nineHundred, eighty, two, nineHundred, eighty, three, nineHundred, eighty, four, nineHundred, eighty, five, nineHundred, eighty, six, nineHundred, eighty, seven, nineHundred, eighty, eight, nineHundred, eighty, nine, nineHundred, ninety, nineHundred, ninety, one, nineHundred, ninety, two, nineHundred, ninety, three, nineHundred, ninety, four, nineHundred, ninety, five, nineHundred, ninety, six, nineHundred, ninety, seven, nineHundred, ninety, eight, nineHundred, ninety, nine, oneThousand

将它们全部添加为18451

另一个答案给出了解释,但你必须考虑

1-9 10-19 数以百计 数千

代表912

首先,9 12 - &gt; Exctract nineHundred,因为912的长度为3

其次,9 1 2 - &gt;如果它是1,则表示我们使用10-19来确定我们使用下一个数字91 2,它可以用作数组中的索引以获得12个。