• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:29
CEST 16:29
KST 23:29
  • 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] Ro16 Preview: Rough Waters8[ASL22] Ro24 Preview: Siren's Call8[ASL22] Ro24 Preview: Summer's End9Serral wins HomeStory Cup 2915Serral wins Maestros of the Game 244
Community News
Weekly Cups (Aug 30-Sep 7): herO thrives amid growing schism0Official StarCraft website teases new content ahead of BlizzCon?111Stellar Fest TWO the Moon (Dec 16-20)9Weekly Cups (August 24-30): Patches' balance mod takes over3New 3v3 BGH Ladder (and more) on ShieldBattery!46
StarCraft 2
General
Weekly Cups (Aug 30-Sep 7): herO thrives amid growing schism Nexon wins bid to develop StarCraft IP content, distribute Overwatch mobile game Balance hotfix patch 5.0.16b (July 16) SC4ALL: II Winner Will Earn a Spot at HSC 30! Weekly Cups (August 24-30): Patches' balance mod takes over
Tourneys
Sea Duckling Open (Global, Bronze-Diamond) 2026 GSTL Announcement Sparkling Tuna Cup - Weekly Open Tournament Stellar Fest TWO the Moon (Dec 16-20) IntoTheTV X SOOP SC2 League : Weekly & Monthly
Strategy
[G] Having the right mentality to improve
Custom Maps
Nexus Wars 2021 GUIDE [M] (2) Industrial Park
External Content
Mutation # 542 The Ascended Mutation # 541 Binary Choice The PondCast: SC2 News & Results Mutation # 540 Dodge This
Brood War
General
Pros React To: Calm's Big Brain Play Vs Mini Official StarCraft website teases new content ahead of BlizzCon? New 3v3 BGH Ladder (and more) on ShieldBattery! ASL22 General Discussion BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[ASL22] Ro16 Group B [ASL22] Ro16 Group A [ASL22] Ro24 Group F [Megathread] Daily Proleagues
Strategy
Simple Questions, Simple Answers Odyssey Mineral Stack Saturation Replay Review Process - What do you do? Game Theory for Starcraft
Other Games
General Games
EVE Corporation Nintendo Switch Thread Diablo IV [Maplestory Hardcore] Let's Play~!! General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
[TL LoL EUW IHs] Teemo shall perish TSM pausing esports and CLG Dead
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Power Rank TL Mafia Community Thread NeO.D_StephenKing vs This Guy From 1 Million Dance
Community
General
Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread US Politics Mega-thread UK Politics Mega-thread Artificial Intelligence Thread
Fan Clubs
MarineLorD Fan Club The Creator Fan Club The ShoWTimE Fan Club
Media & Entertainment
Movie Discussion! Anime Discussion Thread
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
The Automated Ban List Northern Ireland Global Starcraft
Blogs
F* the Children and Get Off …
TrAiDoS
Dreaming of BW patches (mod…
c3rberUs
Regacy Esports: The Bh…
regacyesports
LOCKPICKING NOOB
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 7045 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
GSL
11:00
2026 GSTL: Main Stage Day 5
IntoTheiNu 928
CranKy Ducklings SOOP185
Rex28
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SHIN 120
Maru 70
Classic 37
herO (SOOP) 31
Trap 30
Rex 28
Zoun (SOOP) 20
Solar (SOOP) 7
StarCraft: Brood War
Britney 58789
Calm 5574
Bisu 1735
ggaemo 1496
EffOrt 1378
Light 410
Rush 307
Mini 301
actioN 266
Stork 234
[ Show more ]
Soulkey 195
Snow 165
Larva 157
Hyun 136
hero 136
Mind 93
Sea.KH 77
Barracks 65
Sharp 64
ToSsGirL 52
soO 33
Aegong 26
Terrorterran 25
HiyA 17
SilentControl 16
Rock 14
Shine 13
Yoon 5
Dota 2
qojqva3536
Dendi1643
420jenkins405
syndereN383
Counter-Strike
markeloff278
edward68
Super Smash Bros
hungrybox673
Other Games
hiko917
B2W.Neo810
Lowko432
crisheroes291
Hui .280
XaKoH 277
Liquid`VortiX270
Liquid`RaSZi178
ArmadaUGS54
QueenE41
Trikslyr17
Organizations
Other Games
BasetradeTV20
Algost 5
[ Show 13 non-featured ]
StarCraft 2
• StrangeGG 70
• Gemini_19 5
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis2376
• Jankos2012
• TFBlade569
Upcoming Events
PiGosaur Cup
9h 31m
Kung Fu Cup
20h 31m
Replay Cast
1d 9h
The PondCast
1d 19h
KCM Race Survival
1d 19h
Escore
2 days
IntoTheTV X SOOP
2 days
CranKy Ducklings
3 days
Sparkling Tuna Cup
4 days
Shopify Rebellion Sundays
5 days
Spirit vs Mixu
Clem vs TBD
[ Show More ]
RSL Revival
5 days
Replay Cast
5 days
Afreeca Starleague
5 days
WardiTV Weekly
5 days
Afreeca Starleague
6 days
GSL
6 days
Liquipedia Results

Completed

Proleague 2026-09-02
PiG Sty Festival 8.0
Big Dog Cup 2026 Div 1

Ongoing

KCM Race Survival 2026 Season 3
K-JUNGMAN
ASL Season 22
Super Anchor Qualifying S3
CSL 2026 AUTUMN (S22)
Acropolis #5
Acropolis #5 - TRS
RSL Revival: Season 6
Calamity Invitational
FISSURE Playground #3
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026

Upcoming

Escore Tournament S3: King of Kings
Acropolis #5 - GSA
Blizzard Classic Cup 2026
Acropolis #5 - GSB
Acropolis #5 - GSC
SC4ALL II: Brood War
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
Stake Ranked Episode 6
BLAST Rivals Fall 2026
IEM Beijing 2026
Stake Ranked Episode 5
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
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.