File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ const rl = require ( "readline" ) . createInterface ( { input : process . stdin } ) ;
2+ var iter = rl [ Symbol . asyncIterator ] ( ) ;
3+ const readline = async ( ) => ( await iter . next ( ) ) . value ;
4+
5+ void ( async function ( ) {
6+ let l ;
7+ let r ;
8+ while ( ( line = await readline ( ) ) ) {
9+ let tokens = line . split ( " " ) ;
10+ l = parseInt ( tokens [ 0 ] ) ;
11+ r = parseInt ( tokens [ 1 ] ) ;
12+ // console.log(a + b);
13+ }
14+ const rF = Math . floor ( Math . pow ( r , 1 / 2 ) ) ;
15+ const lF = Math . ceil ( Math . pow ( l , 1 / 2 ) ) ;
16+ console . log ( rF - lF + 1 ) ;
17+ } ) ( ) ;
Original file line number Diff line number Diff line change 1+ const rl = require ( "readline" ) . createInterface ( { input : process . stdin } ) ;
2+ var iter = rl [ Symbol . asyncIterator ] ( ) ;
3+ const readline = async ( ) => ( await iter . next ( ) ) . value ;
4+
5+ void ( async function ( ) {
6+ let kq ;
7+ let flag = true ;
8+ const query = [ ] ;
9+ while ( ( line = await readline ( ) ) ) {
10+ // console.log(line)
11+ if ( flag ) {
12+ kq = line . split ( " " ) ;
13+ // console.log(kq)
14+ flag = false ;
15+ } else {
16+ query . push ( Number ( line ) ) ;
17+ }
18+ }
19+ k = Number ( kq [ 0 ] ) ;
20+ q = Number ( kq [ 1 ] ) ;
21+
22+ const f = new Array ( k ) . fill ( 1 ) ;
23+ f . push ( k ) ;
24+ let cur = k ;
25+ const nMax = Math . max ( ...query ) ;
26+ // console.log(nMax)
27+ const BASE = 10 ** 9 + 7 ;
28+ for ( let i = 0 ; i < nMax - k ; i ++ ) {
29+ cur = cur - f [ i ] + f [ i + k ] ;
30+ f . push ( cur % BASE ) ;
31+ }
32+ for ( const que of query ) {
33+ console . log ( f [ que - 1 ] ) ;
34+ }
35+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments