• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 04:31
CET 09:31
KST 17:31
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL22] Finals Preview: Sweet Victory!9[ASL22] Ro4 Preview: Mirror Mirror6[ASL22] Ro8 Preview: Within Reach5[ASL22] Ro8 Preview: In A Tizzy11[ASL22] Ro16 Preview: Holy Diver5
Community News
Evil Geniuses - shutting down14ISSL (IntoTheTV x SOOP SC2 League): Premier5Weekly Cups (October 12-18): 5.0.17 era begins1[$1250] International ShieldBattery League64Weekly Cups (October 5-11): Farewell to 5.0.167
StarCraft 2
General
No more SC2 streamers on team liquid? REPORT: StarCraft 2: Remastered In Development Evil Geniuses - shutting down How do you feel about the mass reverts in the 5.0.17 PTR? Daily SC2 Player Grid - feedback wanted
Tourneys
ScienceCraft (October 24-25) - Live Event RSL goes to London! 2026 Offline Finals Nov 21-22 ISSL (IntoTheTV x SOOP SC2 League): Premier Sparkling Tuna Cup - Weekly Open Tournament WORTEX Challenger Series — Open SC2 LAN in Budapes
Strategy
[H] ZvP Mid-Late Game: Stalkers Collossi HT
Custom Maps
[G] How to playtest arcade maps [A] Nemrods 1/4 players [M] (2) Sweltering Sands
External Content
Mutation # 548 Shining Bright The PondCast: SC2 News & Results Mutation # 547 Temple Of Terror Mutation # 546 Catch the Train
Brood War
General
Rollback Netcode in Brood War [Recap] 0-6 Defeat for Mong's Team Bot on ladder Young Players Tournament Announced by SOOP Starcraft player cRuZa Passed away.
Tourneys
[$1250] International ShieldBattery League [BSL23] RO24 Group C Small VOD Thread 2.0 2v2v2v2 Tournament
Strategy
Cliff Jump Revisited (1 in a 1000 strategy) 50,000-Word Terran Builds Memo 2026-10-22 Simple Questions, Simple Answers
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Armies of Exigo - YesYes? General RTS Discussion Thread Dawn of War IV
Dota 2
Dota 2 Champions League Season 3 Begins April 25!
League of Legends
[TL LoL EUW IHs] Teemo shall perish
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Canadian Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Artificial Intelligence Thread
Fan Clubs
Serral Fan Club
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Recent Gifted Posts
Blogs
Innovate or Game Over?
TrAiDoS
ShieldBattery on Mac
Kraekkling
[ASL22] Ro4 Day1 Ticket Giv…
bITt.mAN
Can Bots Beat Pros?? Starcr…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 8359 users

[SC2B Key Contest]Math challenge - Page 2

Blogs > yh8c4
Post a Reply
Prev 1 2 3 Next All
Nemesis
Profile Blog Joined May 2009
Canada2568 Posts
May 01 2010 23:26 GMT
#21
the answer is 59!
Lee Young Ho fighting! KT P are just CHINTOSSTIC.
yh8c4
Profile Blog Joined July 2009
108 Posts
May 01 2010 23:27 GMT
#22
On May 02 2010 08:24 Sadistx wrote:
From what I understand, it will be a pretty big number, around 29000000000000000.

I have no means of actually solving this without getting a programming language that handles huge numbers and writing code for it.

I'm sure one of the math majors on here has a better way than brute forcing it.


that's a good start, the correct solution has the same number of digits
Sadistx
Profile Blog Joined February 2009
Zimbabwe5568 Posts
May 01 2010 23:28 GMT
#23
On May 02 2010 08:26 Nemesis wrote:
the answer is 59!


59! gives you a number that's more than 10^18 so its obviously wrong.
ghrur
Profile Blog Joined May 2009
United States3786 Posts
May 01 2010 23:30 GMT
#24
23473423423423427
:D
darkness overpowering
Nehsb
Profile Joined May 2009
United States380 Posts
Last Edited: 2010-05-01 23:50:19
May 01 2010 23:47 GMT
#25
i think you can solve it by splitting it up into two overlapping pieces, an 10^11 size piece and a 10^10 size piece, write arrays for "certain values", and then calculate the number that sum to 0....

That shouldn't take too long...

edit: I forgot my comp can't store int arr[10000000000]

Does anyone know how to store that?

edit2: nvm you only need to store long long arr[199];
jannis
Profile Joined April 2010
Netherlands38 Posts
May 02 2010 00:01 GMT
#26
just to be sure: do you mean the digital sum or the reduced digital sum (that is, applying the digital sum until the number is in the range 0-9)?
hello 8]
Thratur
Profile Blog Joined June 2008
Canada917 Posts
May 02 2010 00:02 GMT
#27
My source code is running but is taking quite some time
Nehsb
Profile Joined May 2009
United States380 Posts
May 02 2010 00:03 GMT
#28
On May 02 2010 09:01 jannis wrote:
just to be sure: do you mean the digital sum or the reduced digital sum (that is, applying the digital sum until the number is in the range 0-9)?


it says ds(solution) = 59, so I'm pretty sure it's digit sum...
yh8c4
Profile Blog Joined July 2009
108 Posts
May 02 2010 00:05 GMT
#29
On May 02 2010 09:01 jannis wrote:
just to be sure: do you mean the digital sum or the reduced digital sum (that is, applying the digital sum until the number is in the range 0-9)?


ds(999) = 27
Nehsb
Profile Joined May 2009
United States380 Posts
May 02 2010 00:11 GMT
#30
k I finished writing the program, and it should run in time, but it crashes...

do you accept it if we send you the code, without the answer, but with a description of how we tried to find the answer and why it should run in < a minute?
Hamster1800
Profile Blog Joined August 2008
United States175 Posts
May 02 2010 00:18 GMT
#31
I PMed my answer and a description. Code runs in 1.128s on my box
D is for Diamond, E is for Everything Else
Nehsb
Profile Joined May 2009
United States380 Posts
May 02 2010 00:20 GMT
#32
On May 02 2010 09:18 Hamster1800 wrote:
I PMed my answer and a description. Code runs in 1.128s on my box




What was your code btw?

Mine:

#include<iostream>
#include<stdlib.h>

using namespace std;

int digitSum(long long num);

int main(){
long long arr1[301][137];
long long arr2[301][137];
for(int i = 0; i < 301; i++){
for(int j = 0; j < 137; j++){
arr1[i][j] = arr2[i][j] = 0;
}
}
for(long long i = 0; i < 100000000; i++){
long long num = digitSum((137 * i) % 1000000000) - digitSum(i);
long long num2 = (137 * i) / 1000000000;
arr1[150+num][num2]++;
}
for(long long i = 0; i < 1000000000; i++){
for(int j = 0; j < 137; j++){
int num = digitSum(137 * i + j) - digitSum(i);
arr2[150+num][j]++;
}
}
long long answer = 0;
for(int i = 0; i <= 1000; i++){
for(int j = 0; j < 137; j++){
answer += arr1[i][j]*arr2[300 - i][j];
}
}
cout << answer << endl;
return 0;
}

int digitSum(long long num){
if(num == 0)return 0;
return (num%10) + digitSum(num/10);
}
yh8c4
Profile Blog Joined July 2009
108 Posts
May 02 2010 00:22 GMT
#33
On May 02 2010 09:11 Nehsb wrote:
k I finished writing the program, and it should run in time, but it crashes...

do you accept it if we send you the code, without the answer, but with a description of how we tried to find the answer and why it should run in < a minute?


why do you think it should run in < 1 minute?
Sharkified
Profile Joined January 2009
Canada254 Posts
May 02 2010 00:23 GMT
#34
On May 02 2010 09:18 Hamster1800 wrote:
I PMed my answer and a description. Code runs in 1.128s on my box


I doubt it's your box, you either have an amazing or amazingly bad code.
I have an i7-860 and it takes forever to run my code.
Nehsb
Profile Joined May 2009
United States380 Posts
Last Edited: 2010-05-02 00:26:50
May 02 2010 00:25 GMT
#35
On May 02 2010 09:22 yh8c4 wrote:
Show nested quote +
On May 02 2010 09:11 Nehsb wrote:
k I finished writing the program, and it should run in time, but it crashes...

do you accept it if we send you the code, without the answer, but with a description of how we tried to find the answer and why it should run in < a minute?


why do you think it should run in < 1 minute?


NVM, sorry for some reason I thought my comp ran 200 billion operations per second.

my code probably is more efficient if you replace the arr1 thing with 10^10 and the arr2 thing witih 10^8

edit: that should be like.... (10^10 + 10^8 * 137) * a small number about efficiency?,
Thratur
Profile Blog Joined June 2008
Canada917 Posts
May 02 2010 00:25 GMT
#36
I calculated mine would take appromatively 1000 hours lol

Need to find a way to optimize this...
Hamster1800
Profile Blog Joined August 2008
United States175 Posts
May 02 2010 00:36 GMT
#37
Okay, I got the key, so I'll just put the solution up for people who want to see
+ Show Spoiler +

Answer =
20444710234716473

Solution is a dynamic programming algorithm. State is based on the last k digits of the number, lazily computing the digit sum of 137*x digit by digit, storing the next 4 digits to the left of the last k digits (using the fact that 9*137 + 99 < 10000). I iterate through the values of k from 0 to 17, increasing it by one each time (so that at the end we have the values for 18), computing the number of numbers x for which the next 4 digits to the left are "a" and the difference between ds(x) and ds(137*x) (up to the last k digits) is "b".

Code below:
#include<cstdio>
#include<cstdlib>

using namespace std;

int main() {
long long **now, **next;
now = new long long*[10000];
next = new long long*[10000];
for(int i = 0; i<10000; i++) {
now[i] = new long long[401];
next[i] = new long long[401];
now[i] += 200;
next[i] += 200;
for(int j = -200; j<=200; j++) {
now[i][j] = next[i][j] = 0;
}
}
now[0][0] = 1;
for(int i = 0; i<18; i++) {
for(int j = 0; j<10000; j++) {
for(int k = -200; k<=200; k++) {
next[j][k] = 0;
}
}
for(int a = 0; a<10000; a++) {
for(int b = -162; b<=162; b++) {
for(int d = 0; d<=9; d++) {
int na = a/10 + 137*d, nb = b - a%10 + d;
next[na][nb] += now[a][b];
}
}
}
long long **t = now;
now = next;
next = t;
}
long long ans = 0;
for(int i = 0; i<10000; i++) {
for(int j = -200; j<=200; j++) {
int a = i, b = j;
while(a != 0) {
b -= a%10;
a/=10;
}
if(b == 0) {
ans += now[i][j];
}
}
}
printf("%lld\n",ans);
}
D is for Diamond, E is for Everything Else
yh8c4
Profile Blog Joined July 2009
108 Posts
May 02 2010 00:37 GMT
#38
Hamster1800 is the winner, his solution:


ok, the key is yours:

xxxxxx-xxxx-xxxxxx-xxxx-xxxxxx

have fun

-----------------------------------------
Original Message:
Sure thing
9090754242258600
1710153888867000

-----------------------------------------
Original Message:
could you give me 2 examples for x for which ds(x) = ds(x * 137)?

-----------------------------------------
Original Message:
Answer =
20444710234716473

Solution is a dynamic programming algorithm. State is based on the last k digits of the number, lazily computing the digit sum of 137*x digit by digit, storing the next 4 digits to the left of the last k digits (using the fact that 9*137 + 99 < 10000). I iterate through the values of k from 0 to 17, increasing it by one each time (so that at the end we have the values for 18), computing the number of numbers x for which the next 4 digits to the left are "a" and the difference between ds(x) and ds(137*x) (up to the last k digits) is "b".

Code below:

#include<cstdio>
#include<cstdlib>

using namespace std;

int main() {
long long **now, **next;
now = new long long*[10000];
next = new long long*[10000];
for(int i = 0; i<10000; i++) {
now[i] = new long long[401];
next[i] = new long long[401];
now[i] += 200;
next[i] += 200;
for(int j = -200; j<=200; j++) {
now[i][j] = next[i][j] = 0;
}
}
now[0][0] = 1;
for(int i = 0; i<18; i++) {
for(int j = 0; j<10000; j++) {
for(int k = -200; k<=200; k++) {
next[j][k] = 0;
}
}
for(int a = 0; a<10000; a++) {
for(int b = -162; b<=162; b++) {
for(int d = 0; d<=9; d++) {
int na = a/10 + 137*d, nb = b - a%10 + d;
next[na][nb] += now[a][b];
}
}
}
long long **t = now;
now = next;
next = t;
}
long long ans = 0;
for(int i = 0; i<10000; i++) {
for(int j = -200; j<=200; j++) {
int a = i, b = j;
while(a != 0) {
b -= a%10;
a/=10;
}
if(b == 0) {
ans += now[i][j];
}
}
}
printf("%lld\n",ans);
}

Sharkified
Profile Joined January 2009
Canada254 Posts
May 02 2010 00:38 GMT
#39
Congratz, you sir are a better programmer than I am.
eddoo
Profile Joined March 2010
30 Posts
Last Edited: 2010-05-02 00:59:43
May 02 2010 00:56 GMT
#40
Argh, I managed to hand count that number using combinatorics and on the verge of victory refresh to see a dynamic algorithm win.

edit: I used the ds(x) = 59 hint though. Good job hamster
Prev 1 2 3 Next All
Please log in or register to reply.
Live Events Refresh
Next event in 1h 30m
[ Submit Event ]
Live Streams
Refresh
StarCraft: Brood War
Shuttle 2347
firebathero 713
Mind 428
Larva 285
Hyuk 199
Leta 182
Barracks 122
Killer 109
Stork 109
Mong 96
[ Show more ]
scan(afreeca) 64
Shinee 61
ToSsGirL 51
Bale 34
Free 32
Movie 31
Shine 30
NaDa 26
ZergMaN 22
Yoon 21
yabsab 16
zelot 10
soO 7
Counter-Strike
Sick64
Other Games
summit1g10887
Organizations
Counter-Strike
PGL12657
Other Games
gamesdonequick1092
StarCraft: Brood War
UltimateBattle 14
[ Show 8 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Upcoming Events
FEL
1h 30m
Sparkling Tuna Cup
1h 30m
Replay Cast
14h 30m
WardiTV Weekly
1d 3h
IntoTheTV X SOOP
2 days
ByuN vs Lambo
MaxPax vs Bunny
PiGosaur Cup
2 days
The PondCast
3 days
Kung Fu Cup
3 days
IntoTheTV X SOOP
4 days
SHIN vs GuMiho
Clem vs Classic
WardiTV Invitational
5 days
[ Show More ]
GSL
5 days
Epic.LAN
5 days
Replay Cast
5 days
Sparkling Tuna Cup
6 days
Epic.LAN
6 days
Liquipedia Results

Completed

Acropolis #5 - GSC
Blizzard Classic Cup 2026
HCC Season 3

Ongoing

Acropolis #5
KCM Race Survival 2026 Season 4
BSL Season 23
PGL Masters Bucharest 2026
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
BLAST Open Fall 2026
Esports World Cup 2026

Upcoming

IPSL Winter 2026-27
SC4ALL II: Brood War
BSL 23: Non-Korean Championship
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
eXTREMESLAND 2026
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
IEM Beijing 2026
Stake Ranked Episode 5
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.