結果
問題 |
No.1185 完全な3の倍数
|
ユーザー |
![]() |
提出日時 | 2020-08-25 13:14:02 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 134 ms / 2,000 ms |
コード長 | 824 bytes |
コンパイル時間 | 1,737 ms |
コンパイル使用メモリ | 73,892 KB |
実行使用メモリ | 54,232 KB |
最終ジャッジ日時 | 2024-11-24 09:49:27 |
合計ジャッジ時間 | 7,769 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 |
ソースコード
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws java.lang.Exception { // your code goes here // 入力 Scanner sc = new Scanner(System.in); int N = sc.nextInt(); // カウント int count = 0; if(N < 100){ count = N / 3 - 3; }else{ count = 30; int id = 16; long num = baseConvert(id) * 3L; while(num <= N){ count++; id++; num = baseConvert(id) * 3L; } } // 出力 System.out.println(count); } // 10進数→4進数変換関数 public static int baseConvert(int num){ int output = 0; int digit = 1; while(num > 0){ int amari = num % 4; output += amari * digit; num = num / 4; digit *= 10; } return output; } }