Amazing Four-Digit Numbers

Time limit1sMemory limit128 MB

Summary
Print every four-digit number whose digit sum is the same when written in base 10, base 12, and base 16.
Level

Medium4 of 10

Topics
Implementation, Number theory, Brute force
Solved
No attempts yet

Problem

Write a four-digit number nn (1000≤n≤99991000 \le n \le 9999) in base 10, base 12, and base 16. If the sum of its digits is the same in all three bases, then nn is called an amazing four-digit number.

Find every amazing four-digit number and print them in ascending order.

Input

There is no input.

Output

Print every amazing four-digit number in ascending order, one per line.

Hint

The smallest amazing four-digit number is 29922992.

Examples6

  1. Example 1

    Input
    Expected output
    2992
    2993
    2994
    2995
    2996
    2997
    2998
    2999
    4470
    4471
    4472
    4473
    4474
    4475
    4970
    4971
    4972
    4973
    4974
    4975
    5460
    5461
    5462
    5463
    5464
    5465
    5466
    5467
    5468
    5469
    5960
    5961
    5962
    5963
    6456
    6457
    6458
    6459
    7440
    7441
    7442
    7443
    7444
    7445
    7446
    7447
    7448
    7449
    7940
    7941
    7942
    7943
    8436
    8437
    8438
    8439
    9424
    9425
    9426
    9427
    9428
    9429
    9924
    9925
    9926
    9927
    9928
    9929
    
  2. Example 2

    Input
    Expected output
    2992
    2993
    2994
    2995
    2996
    2997
    2998
    2999
    4470
    4471
    4472
    4473
    4474
    4475
    4970
    4971
    4972
    4973
    4974
    4975
    5460
    5461
    5462
    5463
    5464
    5465
    5466
    5467
    5468
    5469
    5960
    5961
    5962
    5963
    6456
    6457
    6458
    6459
    7440
    7441
    7442
    7443
    7444
    7445
    7446
    7447
    7448
    7449
    7940
    7941
    7942
    7943
    8436
    8437
    8438
    8439
    9424
    9425
    9426
    9427
    9428
    9429
    9924
    9925
    9926
    9927
    9928
    9929
    
  3. Example 3

    Input
    Expected output
    2992
    2993
    2994
    2995
    2996
    2997
    2998
    2999
    4470
    4471
    4472
    4473
    4474
    4475
    4970
    4971
    4972
    4973
    4974
    4975
    5460
    5461
    5462
    5463
    5464
    5465
    5466
    5467
    5468
    5469
    5960
    5961
    5962
    5963
    6456
    6457
    6458
    6459
    7440
    7441
    7442
    7443
    7444
    7445
    7446
    7447
    7448
    7449
    7940
    7941
    7942
    7943
    8436
    8437
    8438
    8439
    9424
    9425
    9426
    9427
    9428
    9429
    9924
    9925
    9926
    9927
    9928
    9929
    
  4. Example 4

    Input
    Expected output
    2992
    2993
    2994
    2995
    2996
    2997
    2998
    2999
    4470
    4471
    4472
    4473
    4474
    4475
    4970
    4971
    4972
    4973
    4974
    4975
    5460
    5461
    5462
    5463
    5464
    5465
    5466
    5467
    5468
    5469
    5960
    5961
    5962
    5963
    6456
    6457
    6458
    6459
    7440
    7441
    7442
    7443
    7444
    7445
    7446
    7447
    7448
    7449
    7940
    7941
    7942
    7943
    8436
    8437
    8438
    8439
    9424
    9425
    9426
    9427
    9428
    9429
    9924
    9925
    9926
    9927
    9928
    9929
    
  5. Example 5

    Input
    Expected output
    2992
    2993
    2994
    2995
    2996
    2997
    2998
    2999
    4470
    4471
    4472
    4473
    4474
    4475
    4970
    4971
    4972
    4973
    4974
    4975
    5460
    5461
    5462
    5463
    5464
    5465
    5466
    5467
    5468
    5469
    5960
    5961
    5962
    5963
    6456
    6457
    6458
    6459
    7440
    7441
    7442
    7443
    7444
    7445
    7446
    7447
    7448
    7449
    7940
    7941
    7942
    7943
    8436
    8437
    8438
    8439
    9424
    9425
    9426
    9427
    9428
    9429
    9924
    9925
    9926
    9927
    9928
    9929
    
  6. Example 6

    Input
    Expected output
    2992
    2993
    2994
    2995
    2996
    2997
    2998
    2999
    4470
    4471
    4472
    4473
    4474
    4475
    4970
    4971
    4972
    4973
    4974
    4975
    5460
    5461
    5462
    5463
    5464
    5465
    5466
    5467
    5468
    5469
    5960
    5961
    5962
    5963
    6456
    6457
    6458
    6459
    7440
    7441
    7442
    7443
    7444
    7445
    7446
    7447
    7448
    7449
    7940
    7941
    7942
    7943
    8436
    8437
    8438
    8439
    9424
    9425
    9426
    9427
    9428
    9429
    9924
    9925
    9926
    9927
    9928
    9929