Home
Problem
Status
Contest
Workbook
User
Group
Forum
Register
Login
{"managingGroups":{},"author":"swfxliyiyu","updateTime":1500379264000,"title":"Problem - UVA 679 - Dropping Balls","dislikeCnt":1,"content":"思路:球到某结点时,先考虑该结点之前经过多少球。程序逻辑没问题,提交runtime error。\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc \u003d new Scanner(System.in);\n int caseNum \u003d sc.nextInt();\n for (int i \u003d 0; i \u003c caseNum; i++) {\n int D \u003d sc.nextInt();\n int I \u003d sc.nextInt() - 1;\n Point root \u003d new Point(I, 1);\n Point leaf \u003d root;\n for (int deep \u003d 1; deep \u003c D; deep++) {\n leaf.fallDown();\n }\n System.out.println(leaf.node);\n }\n\n }\n\n\n\n}\n\nclass Point {\n public int ballNum;\n public int node;\n public Point(int ballNum, int node) {\n this.ballNum \u003d ballNum;\n this.node \u003d node;\n }\n public void fallDown() {\n if (ballNum % 2 \u003d\u003d 0) {\n this.node *\u003d 2;\n this.ballNum /\u003d 2;\n } else {\n this.node \u003d this.node * 2 + 1;\n this.ballNum \u003d (this.ballNum - 1) / 2;\n }\n }\n\n}","threadId":15734,"likeCnt":0,"createTime":1500379264000,"isWorkbook":false,"viewCnt":2566,"openness":2,"fav":false,"id":165,"trustable":false}