現在Aize Online Judgeの問題に取り掛かり始めたものです。
取り組んでいる問題
以下のコードではメモリの使用量が多すぎてオンラインジャッジがうまくいきません。
どの部分がメモリを浪費してしまっているのでしょうか?
lang
1import java.util.Scanner; 2 3public class Main { 4 public static void main(String[] args) { 5 Scanner scan = new Scanner(System.in); 6 String text = new String(); 7 int num; 8 int count = 1; 9 while (true) { 10 num = scan.nextInt(); 11 if (num == 0) { 12 scan.close(); 13 System.out.println(text); 14 break; 15 } else { 16 text += "Case " + count + ": " + num + "\n"; 17 count++; 18 } 19 } 20 } 21 22}
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/07/13 11:05