• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 19:10
CEST 01:10
KST 08:10
  • 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
Code S Season 1 - RO8 Preview3[ASL21] Ro8 Preview Pt2: Progenitors8Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun13[ASL21] Ro8 Preview Pt1: Inheritors16[ASL21] Ro16 Preview Pt2: All Star10
Community News
Weekly Cups (April 27-May 4): Clem takes triple0RSL Revival: Season 5 - Qualifiers and Main Event11Code S Season 1 (2026) - RO12 Results12026 GSL Season 1 Qualifiers25Maestros of the Game 2 announced9
StarCraft 2
General
Code S Season 1 - RO8 Preview Behind the Blue - Team Liquid History Book Weekly Cups (April 27-May 4): Clem takes triple Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Code S Season 1 (2026) - RO12 Results
Tourneys
GSL Code S Season 1 (2026) Sparkling Tuna Cup - Weekly Open Tournament RSL Revival: Season 5 - Qualifiers and Main Event StarCraft Evolution League (SC Evo Biweekly) 2026 GSL Season 2 Qualifiers
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 524 Death and Taxes The PondCast: SC2 News & Results Mutation # 523 Firewall Mutation # 522 Flip My Base
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ (Spoiler) Asl ro8 D winner interview BW General Discussion Do we have a pimpest plays list? AI Question
Tourneys
[ASL21] Ro8 Day 4 [ASL21] Ro8 Day 3 [Megathread] Daily Proleagues [ASL21] Ro8 Day 2
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates What's the deal with APM & what's its true value Any training maps people recommend?
Other Games
General Games
Nintendo Switch Thread Dawn of War IV Stormgate/Frost Giant Megathread OutLive 25 (RTS Game) Daigo vs Menard Best of 10
Dota 2
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
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread European Politico-economics QA Mega-thread 3D technology/software discussion Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread Formula 1 Discussion McBoner: A hockey love story
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Movie Stars In Video Games: …
TrAiDoS
ramps on octagon
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1735 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 10h 20m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
PiGStarcraft356
StarCraft: Brood War
Britney 10588
Artosis 526
NaDa 16
Dota 2
monkeys_forever609
Super Smash Bros
hungrybox8
Other Games
summit1g6321
tarik_tv6084
Liquid`RaSZi1636
shahzam456
uThermal206
C9.Mang0186
ToD109
UpATreeSC49
ViBE25
Organizations
Other Games
BasetradeTV534
gamesdonequick226
Dota 2
PGL Dota 2 - Main Stream38
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 13 non-featured ]
StarCraft 2
• OhrlRock 4
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• masondota21454
League of Legends
• imaqtpie2689
Upcoming Events
GSL
10h 20m
SHIN vs Zoun
ByuN vs herO
OSC
11h 50m
OSC
13h 50m
Replay Cast
1d
Escore
1d 10h
The PondCast
1d 10h
WardiTV Invitational
1d 11h
Zoun vs Ryung
Lambo vs ShoWTimE
Big Brain Bouts
1d 16h
Fjant vs Bly
Serral vs Shameless
OSC
1d 22h
Replay Cast
2 days
[ Show More ]
CranKy Ducklings
2 days
RSL Revival
2 days
SHIN vs Bunny
ByuN vs Shameless
WardiTV Invitational
2 days
Krystianer vs TriGGeR
Cure vs Rogue
uThermal 2v2 Circuit
2 days
BSL
2 days
Replay Cast
3 days
Sparkling Tuna Cup
3 days
RSL Revival
3 days
Cure vs Zoun
Clem vs Lambo
WardiTV Invitational
3 days
BSL
3 days
GSL
4 days
Afreeca Starleague
4 days
Soma vs Leta
Monday Night Weeklies
4 days
CranKy Ducklings
5 days
Afreeca Starleague
5 days
Light vs Flash
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2026-05-05
WardiTV TLMC #16
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
Acropolis #4
YSL S3
SCTL 2026 Spring
RSL Revival: Season 5
2026 GSL S1
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026

Upcoming

Escore Tournament S2: W6
KK 2v2 League Season 1
BSL 22 Non-Korean Championship
Escore Tournament S2: W7
Escore Tournament S2: W8
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
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.