File tree Expand file tree Collapse file tree 2 files changed +24
-10
lines changed
Expand file tree Collapse file tree 2 files changed +24
-10
lines changed Original file line number Diff line number Diff line change 1+ const fs = require ( "fs" ) ;
2+ const filePath = process . platform === "linux" ? "/dev/stdin" : "./서정우/input.txt" ;
3+ const input = fs . readFileSync ( filePath ) . toString ( ) . trim ( ) . split ( "\n" ) ;
4+
5+ const s = input [ 0 ] . trim ( ) ;
6+ const t = input [ 1 ] . trim ( ) ;
7+
8+ const gcd = ( a , b ) => ( b === 0 ? a : gcd ( b , a % b ) ) ;
9+ const lcm = ( a , b ) => ( a * b ) / gcd ( a , b ) ;
10+
11+ const L = lcm ( s . length , t . length ) ;
12+
13+ const repeatToLength = ( str , length ) => {
14+ let result = "" ;
15+ while ( result . length < length ) result += str ;
16+ return result . slice ( 0 , length ) ;
17+ } ;
18+
19+ const sString = repeatToLength ( s , L ) ;
20+ const tString = repeatToLength ( t , L ) ;
21+
22+ console . log ( sString === tString ? 1 : 0 ) ;
Original file line number Diff line number Diff line change 1- 11 12 2 24 10
2- 16 1 13 3 25
3- 6 20 5 21 17
4- 19 4 8 14 9
5- 22 15 7 23 18
6- 5 10 7 16 2
7- 4 22 8 17 13
8- 3 18 1 6 25
9- 12 19 23 14 21
10- 11 24 9 20 15
1+ abc
2+ bca
You can’t perform that action at this time.
0 commit comments