File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ package S5 ;
2
+
3
+ import java .io .*;
4
+ import java .math .BigInteger ;
5
+
6
+ public class Boj_1769_3의배수 {
7
+ public static void main (String [] args ) throws IOException {
8
+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
9
+ BufferedWriter bw = new BufferedWriter (new OutputStreamWriter (System .out ));
10
+ StringBuilder sb = new StringBuilder ();
11
+
12
+ char [] num = br .readLine ().toCharArray ();
13
+ int cnt = 0 ;
14
+
15
+ while (num .length > 1 ) {
16
+ cnt ++;
17
+ BigInteger sum = BigInteger .ZERO ;
18
+
19
+ for (char c : num ) {
20
+ sum = sum .add (new BigInteger (String .valueOf (c )));
21
+ }
22
+
23
+ num = sum .toString ().toCharArray ();
24
+ }
25
+
26
+ sb .append (cnt ).append ('\n' ).append (Integer .parseInt (String .copyValueOf (num )) % 3 == 0 ? "YES" : "NO" );
27
+ bw .write (sb .toString ());
28
+ bw .flush ();
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments