Submission #32374
ソースコード
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.lang.Integer.parseInt; class Main { private final static Scanner in = new Scanner(System.in); private final static PrintWriter out = new PrintWriter(System.out); private void solve() { Color color = new Color(in.nextLine()); QUIT: for (;;) { switch (in.next().charAt(0)) { case 'u' : color.update(getint(), getint(), getint()); break ; case 'd' : color.disp(out); break ; case 'r' : color.reverse(); break ; case 's' : color.shift(getint()); break ; default : break QUIT; } } } private int getint() { return parseInt(in.next()); } public static void main(String[] args) { new Main().solve(); out.close(); } //==================================================================== static class Color { private int color; private static final int MASK = 0xFF; public Color(final String str) { this .color = parseInt(str, 16); } public void update( int R, int G, int B) { int newR = (R == -1) ? this .getR() : R; int newG = (G == -1) ? this .getG() : G; int newB = (B == -1) ? this .getB() : B; this .color = makeRGB(newR, newG, newB); } public void reverse() { this .color = makeRGB( 255 - getR(), 255 - getG(), 255 - getB() ); } public void shift( int N) { if (N < 0) { this .color <<= -N; this .color &= 0xFfFfFf; } else { this .color >>>= N; } } public void disp(PrintWriter out) { out. printf ( "%06X\n" , this .color); } private int getR() { return ( ( this .color >> 16) & MASK ); } private int getG() { return ( ( this .color >> 8) & MASK ); } private int getB() { return ( this .color & MASK ); } private static int makeRGB( int r, int g, int b) { return (r<<16 | g<<8 | b); } } } |
ステータス
項目 | データ |
---|---|
問題 | 0900 - あーるじーびー操作 |
ユーザー名 | Arumakan_ei1727 |
投稿日時 | 2018-03-23 16:55:42 |
言語 | Java |
状態 | Accepted |
得点 | 3 |
ソースコード長 | 2572 Byte |
最大実行時間 | 260 ms |
最大メモリ使用量 | 39528 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 3 / 3 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
input01 | AC | 191 ms | 33708 KB |
1
|
input02 | AC | 158 ms | 35792 KB |
1
|
input03 | AC | 213 ms | 34920 KB |
1
|
input04 | AC | 137 ms | 29916 KB |
1
|
input05 | AC | 226 ms | 38932 KB |
1
|
input06 | AC | 142 ms | 39528 KB |
1
|
input07 | AC | 203 ms | 34552 KB |
1
|
input08 | AC | 185 ms | 37672 KB |
1
|
input09 | AC | 250 ms | 37096 KB |
1
|
input10 | AC | 260 ms | 37928 KB |
1
|
input11 | AC | 250 ms | 37360 KB |
1
|
input12 | AC | 73 ms | 17020 KB |
1
|
input13 | AC | 142 ms | 33916 KB |
1
|
input14 | AC | 139 ms | 32848 KB |
1
|
input15 | AC | 230 ms | 37472 KB |
1
|
input16 | AC | 235 ms | 37596 KB |
1
|
input_sample1 | AC | 75 ms | 17932 KB |
1
|
input_sample2 | AC | 78 ms | 16796 KB |
1
|
input_sample3 | AC | 76 ms | 16500 KB |
1
|
input_sample4 | AC | 73 ms | 19644 KB |
1
|