Safe BigInt Convert
JavaScript
Easy
3 views
Problem Description
One token is given. Convert to BigInt safely. If conversion fails, print BAD. Else print value+1.
Input Format
One token string.
Output Format
One line output.
Sample Test Case
Input:
999999999999999999
Output:
1000000000000000000
Constraints
Token can be very large (up to 1e5 chars).
Official Solution
const fs=require('fs');const t=fs.readFileSync(0,'utf8').trim();if(!t)process.exit(0);try{const x=BigInt(t);process.stdout.write(String(x+1n));}catch(e){process.stdout.write('BAD');}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!