为了账号安全,请及时绑定邮箱和手机立即绑定

在此查找唯一路径数算法中我做错了什么?

在此查找唯一路径数算法中我做错了什么?

慕森王 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 关注
  • 83 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信