• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 17:53
CET 22:53
KST 06:53
  • 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
Team Liquid Map Contest #22 - Presented by Monster Energy5ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13
Community News
Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool30Weekly Cups (March 9-15): herO, Clem, ByuN win42026 KungFu Cup Announcement6BGE Stara Zagora 2026 cancelled12Blizzard Classic Cup - Tastosis announced as captains18
StarCraft 2
General
Potential Updates Coming to the SC2 CN Server Weekly Cups (March 2-8): ByuN overcomes PvT block Weekly Cups (August 25-31): Clem's Last Straw? Weekly Cups (March 9-15): herO, Clem, ByuN win Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool
Tourneys
RSL Season 4 announced for March-April Sparkling Tuna Cup - Weekly Open Tournament WardiTV Team League Season 10 KSL Week 87 [GSL CK] #2: Team Classic vs. Team Solar
Strategy
Custom Maps
WhatsApp +61480852135 - Buy coke dexi in Melbourne Publishing has been re-enabled! [Feb 24th 2026]
External Content
The PondCast: SC2 News & Results Mutation # 517 Distant Threat Mutation # 516 Specter of Death Mutation # 515 Together Forever
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Buy weed dexies in Australia (WhatsApp 0480852135) ASL21 General Discussion Gypsy to Korea JaeDong's form before ASL
Tourneys
[Megathread] Daily Proleagues Buy coke in Brisbane (WhatsApp 0480852135) [BSL22] Open Qualifiers & Ladder Tours Small VOD Thread 2.0
Strategy
Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates
Other Games
General Games
(Telegram@povopackz) - BUY COKE speed 3mmc POLAND General RTS Discussion Thread Nintendo Switch Thread Path of Exile Stormgate/Frost Giant Megathread
Dota 2
Official 'what is Dota anymore' discussion The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread Russo-Ukrainian War Thread Mexico's Drug War
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Movie Discussion! [Req][Books] Good Fantasy/SciFi books [Manga] One Piece
Sports
Formula 1 Discussion 2024 - 2026 Football Thread Tokyo Olympics 2021 Thread General nutrition recommendations Cricket [SPORT]
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Funny Nicknames
LUCKY_NOOB
Money Laundering In Video Ga…
TrAiDoS
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1723 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
BSL
20:00
S22 - Ladder Tour #2
ZZZero.O78
LiquipediaDiscussion
LAN Event
16:30
StarCraft Madness
Airneanach54
Liquipedia
PSISTORM Gaming Misc
15:55
FSL semifinals: PTB vs ASH
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
elazer 289
Nathanias 106
CosmosSc2 73
SpeCial 70
Ketroc 52
Codebar 3
StarCraft: Brood War
Shuttle 343
Dewaltoss 126
ZZZero.O 69
910 17
Dota 2
monkeys_forever336
LuMiX1
Counter-Strike
fl0m5324
shoxiejesuss1889
Heroes of the Storm
Khaldor340
Other Games
Grubby3092
FrodaN1991
JimRising 439
byalli392
ceh9256
Hui .74
JuggernautJason51
Trikslyr42
ViBE19
Organizations
Other Games
gamesdonequick957
Dota 2
PGL Dota 2 - Main Stream80
Other Games
BasetradeTV43
StarCraft 2
angryscii 30
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 19 non-featured ]
StarCraft 2
• Adnapsc2 13
• HeavenSC 7
• Reevou 5
• intothetv
• IndyKCrew
• sooper7s
• AfreecaTV YouTube
• Migwel
• LaughNgamezSOOP
• Kozan
StarCraft: Brood War
• Azhi_Dahaki24
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota21165
• WagamamaTV806
League of Legends
• Doublelift2193
Other Games
• imaqtpie1070
• Shiphtur210
Upcoming Events
RSL Revival
12h 7m
herO vs MaxPax
Rogue vs TriGGeR
BSL
22h 7m
Replay Cast
1d 2h
Replay Cast
1d 11h
Afreeca Starleague
1d 12h
Sharp vs Scan
Rain vs Mong
Wardi Open
1d 14h
Monday Night Weeklies
1d 19h
Sparkling Tuna Cup
2 days
Afreeca Starleague
2 days
Soulkey vs Ample
JyJ vs sSak
Replay Cast
3 days
[ Show More ]
Afreeca Starleague
3 days
hero vs YSC
Larva vs Shine
Kung Fu Cup
3 days
Replay Cast
4 days
KCM Race Survival
4 days
The PondCast
4 days
WardiTV Team League
4 days
Replay Cast
5 days
WardiTV Team League
5 days
RSL Revival
6 days
Cure vs Zoun
WardiTV Team League
6 days
BSL
6 days
Liquipedia Results

Completed

Proleague 2026-03-20
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Jeongseon Sooper Cup
BSL Season 22
CSL Elite League 2026
RSL Revival: Season 4
Nations Cup 2026
NationLESS Cup
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

ASL Season 21
Acropolis #4 - TS6
2026 Changsha Offline CUP
CSL 2026 SPRING (S20)
CSL Season 20: Qualifier 1
Acropolis #4
IPSL Spring 2026
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
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.