File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ process . stdin . resume ( ) ;
2+ process . stdin . setEncoding ( 'ascii' ) ;
3+
4+ var input_stdin = "" ;
5+ var input_stdin_array = "" ;
6+ var input_currentline = 0 ;
7+
8+ process . stdin . on ( 'data' , function ( data ) {
9+ input_stdin += data ;
10+ } ) ;
11+
12+ process . stdin . on ( 'end' , function ( ) {
13+ input_stdin_array = input_stdin . split ( "\n" ) ;
14+ main ( ) ;
15+ } ) ;
16+
17+ function readLine ( ) {
18+ return input_stdin_array [ input_currentline ++ ] ;
19+ }
20+
21+ /////////////// ignore above this line ////////////////////
22+
23+ function pad ( num , size ) {
24+ var s = num + "" ;
25+ while ( s . length < size ) s = "0" + s ;
26+ return s ;
27+ }
28+ function onceInATram ( x ) {
29+ while ( 1 ) {
30+ let left = parseInt ( x [ 0 ] ) + parseInt ( x [ 1 ] ) + parseInt ( x [ 2 ] ) ;
31+ for ( let j = parseInt ( x . slice ( 3 , 6 ) ) + 1 ; j < 1000 ; j ++ )
32+ {
33+ // console.log(j)
34+ let str = pad ( j , 3 ) ;
35+ let right = parseInt ( str [ 0 ] ) + parseInt ( str [ 1 ] ) + parseInt ( str [ 2 ] ) ;
36+ // console.log(right)
37+ if ( left === right )
38+ {
39+ return x . slice ( 0 , 3 ) + str ;
40+ }
41+ }
42+ let nest = parseInt ( x . slice ( 0 , 3 ) ) + 1
43+ x = nest + "000" ;
44+ }
45+ }
46+
47+ function main ( ) {
48+ var x = readLine ( ) ;
49+ var result = onceInATram ( x ) ;
50+ process . stdout . write ( "" + result + "\n" ) ;
51+ }
You can’t perform that action at this time.
0 commit comments