結果
問題 | No.279 木の数え上げ |
ユーザー |
![]() |
提出日時 | 2015-12-10 00:26:27 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 293 ms / 2,000 ms |
コード長 | 934 bytes |
コンパイル時間 | 3,304 ms |
コンパイル使用メモリ | 78,108 KB |
実行使用メモリ | 49,292 KB |
最終ジャッジ日時 | 2024-09-26 05:08:36 |
合計ジャッジ時間 | 8,498 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
import java.util.Scanner; class Tree{ private int t ; private int r ; private int e ; private int treeCount; public Tree(int a,int b,int c){ this.t = a; this.r = b; this.e = c; } public void makeTree(){ while(true){ this.t -= 1; this.r -= 1; this.e -= 2; if(this.t >= 0 && this.r >= 0 && this.e >= 0){ treeCount++; } else{ break; } } } public void showTreeCount(){ System.out.println(this.treeCount); } } public class No_279 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String sample = sc.next(); char[] pieceOfSample = sample.toCharArray(); int tCount = 0; int rCount = 0; int eCount = 0; for(char c:pieceOfSample){ switch(c){ case 't':tCount++;break; case 'r':rCount++;break; case 'e':eCount++;break; } } Tree tree = new Tree(tCount,rCount,eCount); tree.makeTree(); tree.showTreeCount(); } }