亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在此查找唯一路徑數算法中我做錯了什么?

在此查找唯一路徑數算法中我做錯了什么?

慕森王 2022-11-02 15:44:56
問題陳述:https ://pastebin.com/LzvZecyQ我有 2 個輸入文件來測試這個算法。第一: https ://pastebin.com/BtsiZqqn我得到了這個輸出:案例#1:5(這個不錯)二: https ://pastebin.com/fTbdbpnW我得到了這個輸出:案例#1:1案例#2:1案例#3:9案例#4:4案例#5:101案例#6:3.125問題:所有情況都可以,但第 6 次是錯誤的。我正在使用這段代碼:public class DemoApplication {    private static final  Logger LOGGER = Logger.getLogger("com.example.demo.DemoApplication");    private static final String TEMPLATE = "Case #{0}: {1}\r\n";    private static final String PLANET_START = "Galactica";    private static final String PLANET_END = "New Earth";    public static void main(String args[]) {        String inputFilePath = "testInput.txt";        String outputFilePath = "output.txt";        try (BufferedReader reader = Files.newBufferedReader(Paths.get(inputFilePath))) { //Create the reader with the file path of testInput.txt            try (BufferedWriter writer = Files.newBufferedWriter(Paths.get(outputFilePath))) { //Create the writer with the file path we want the output                String line = reader.readLine();//skip first row                int i = 0;//Counter of lines                Map<String, String[]> planets = null;                int caseNumber = 0;我做錯了什么?如果可能的話,我更喜歡解釋為什么這不適用于案例 6,而不是給我解決方案。這是因為我正在嘗試學習算法。這個問題是 tuenti 挑戰的第二個問題(https://contest.tuenti.net/Contest)如果有人有興趣我想你仍然可以參加。提前致謝。
查看完整描述

1 回答

?
尚方寶劍之說

TA貢獻1788條經驗 獲得超4個贊

您的算法似乎運行良好,可能問題出在 MessageFormat.format 方法中,3.125 可能是 3125,點只是千位分隔符。



查看完整回答
反對 回復 2022-11-02
  • 1 回答
  • 0 關注
  • 144 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號