算法 BISHI58 矩形游戏 思路 求解代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StreamTokenizer in = new StreamTokenizer(br); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); in.nextToken(); int n = (int)in.nval; long res = n; while (true) { int a = find(n); n/=a; if(n==1){ res+=1; break; }else{ res+=n; } } out.println(res); out.flush(); out.close(); br.close(); } private static int find(int a) { if(a%2==0){ return 2; } for(int i=3;i*i<=a;i++){ if(a%i==0){ return i; } } return a; }