File tree Expand file tree Collapse file tree 2 files changed +69
-0
lines changed
Expand file tree Collapse file tree 2 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 1+ let input = ''
2+
3+ process . stdin . on ( 'data' , data => input += data )
4+ process . stdin . on ( 'end' , ( ) => {
5+ const lines = input . split ( '\n' )
6+ const [ t ] = lines [ 0 ] . split ( ' ' ) . map ( Number )
7+ for ( let kase = 1 ; kase <= t ; kase ++ ) {
8+ let s = lines [ kase * 2 ]
9+ let hasUpper = false ; let hasLower = false ; let hasDigit = false ; let hasSpe = false
10+ for ( const ch of s ) {
11+ if ( ch . charCodeAt ( 0 ) >= 'A' . charCodeAt ( 0 ) && ch . charCodeAt ( 0 ) <= 'Z' . charCodeAt ( 0 ) ) hasUpper = true
12+ if ( ch . charCodeAt ( 0 ) >= 'a' . charCodeAt ( 0 ) && ch . charCodeAt ( 0 ) <= 'z' . charCodeAt ( 0 ) ) hasLower = true
13+ if ( ch . charCodeAt ( 0 ) >= '0' . charCodeAt ( 0 ) && ch . charCodeAt ( 0 ) <= '9' . charCodeAt ( 0 ) ) hasDigit = true
14+ if ( '#@*&' . includes ( ch ) ) hasSpe = true
15+ }
16+ if ( ! hasUpper ) s += 'A'
17+ if ( ! hasLower ) s += 'a'
18+ if ( ! hasDigit ) s += '1'
19+ if ( ! hasSpe ) s += '#'
20+ while ( s . length < 7 ) s += 'A'
21+
22+ console . log ( `Case #${ kase } : ${ s } ` )
23+ }
24+ } )
Original file line number Diff line number Diff line change 1+ let input = ''
2+
3+ process . stdin . on ( 'data' , data => input += data )
4+ process . stdin . on ( 'end' , ( ) => {
5+ const lines = input . split ( '\n' )
6+ const [ t ] = lines [ 0 ] . split ( ' ' ) . map ( Number )
7+ for ( let kase = 1 ; kase <= t ; kase ++ ) {
8+ const [ n , x , y ] = lines [ kase ] . split ( ' ' ) . map ( Number )
9+
10+ const sum = ( 1 + n ) * n / 2
11+ if ( sum % ( x + y ) === 0 ) {
12+ // 是否分给 a
13+ const sa = Array ( n + 1 ) . fill ( 0 )
14+ const a = sum / ( x + y ) * x ; const b = sum - a
15+ const r = a % ( 1 + n ) ; let times = Math . floor ( a / ( 1 + n ) )
16+ const rb = b % ( 1 + n ) ; const timesB = Math . floor ( b / ( 1 + n ) )
17+ if ( timesB === 0 ) {
18+ for ( let i = 1 ; i <= n ; i ++ ) {
19+ if ( i === rb ) sa [ i ] = 0
20+ else sa [ i ] = 1
21+ }
22+ } else {
23+ sa [ r ] = 1
24+ for ( let i = 1 ; times > 0 ; i ++ ) {
25+ if ( r === i || r === ( n + 1 - i ) ) continue
26+ sa [ i ] = sa [ n + 1 - i ] = 1
27+ times -= 1
28+ }
29+ }
30+ console . log ( `Case #${ kase } : POSSIBLE` )
31+ let s = '' ; let cnt = 0
32+ for ( let i = 1 ; i <= n ; i ++ ) {
33+ if ( sa [ i ] ) {
34+ if ( s . length ) s += ' '
35+ s += i
36+ cnt ++
37+ }
38+ }
39+ console . log ( cnt )
40+ console . log ( s )
41+ } else {
42+ console . log ( `Case #${ kase } : IMPOSSIBLE` )
43+ }
44+ }
45+ } )
You can’t perform that action at this time.
0 commit comments