• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 19:29
CET 01:29
KST 09: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
HomeStory Cup 28 - Info & Preview11Rongyi Cup S3 - Preview & Info3herO wins SC2 All-Star Invitational14SC2 All-Star Invitational: Tournament Preview5RSL Revival - 2025 Season Finals Preview8
Community News
Weekly Cups (Jan 19-25): Bunny, Trigger, MaxPax win3Weekly Cups (Jan 12-18): herO, MaxPax, Solar win0BSL Season 2025 - Full Overview and Conclusion8Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets4$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)39
StarCraft 2
General
StarCraft 2 Not at the Esports World Cup 2026 HomeStory Cup 28 - Info & Preview Weekly Cups (Jan 19-25): Bunny, Trigger, MaxPax win Oliveira Would Have Returned If EWC Continued herO wins SC2 All-Star Invitational
Tourneys
HomeStory Cup 28 $21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7) KSL Week 85 OSC Season 13 World Championship $70 Prize Pool Ladder Legends Academy Weekly Open!
Strategy
Simple Questions Simple Answers
Custom Maps
[A] Starcraft Sound Mod
External Content
Mutation # 511 Temple of Rebirth The PondCast: SC2 News & Results Mutation # 510 Safety Violation Mutation # 509 Doomsday Report
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Liquipedia.net NEEDS editors for Brood War Can someone share very abbreviated BW cliffnotes? BW General Discussion [ASL21] Potential Map Candidates
Tourneys
[Megathread] Daily Proleagues Small VOD Thread 2.0 Azhi's Colosseum - Season 2 [BSL21] Non-Korean Championship - Starts Jan 10
Strategy
Zealot bombing is no longer popular? Simple Questions, Simple Answers Current Meta Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Battle Aces/David Kim RTS Megathread Nintendo Switch Thread Path of Exile Mobile Legends: Bang Bang Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
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
Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread Russo-Ukrainian War Thread European Politico-economics QA Mega-thread
Fan Clubs
The herO Fan Club! The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Let's Get Creative–Video Gam…
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1620 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
Replay Cast
00:00
WardiTV Mondays #70
CranKy Ducklings78
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
ProTech129
JuggernautJason67
RuFF_SC2 5
StarCraft: Brood War
Artosis 763
Shuttle 213
Dota 2
syndereN760
monkeys_forever271
canceldota64
League of Legends
JimRising 599
C9.Mang0269
Counter-Strike
taco 489
minikerr23
Super Smash Bros
AZ_Axe159
Other Games
tarik_tv16161
gofns9216
FrodaN7987
summit1g6338
Liquid`RaSZi1578
KnowMe197
Maynarde113
Livibee78
ViBE75
ToD51
Chillindude35
Organizations
Other Games
gamesdonequick1555
BasetradeTV60
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 21 non-featured ]
StarCraft 2
• Hupsaiya 88
• Berry_CruncH68
• RyuSc2 45
• Response 7
• HeavenSC 3
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• intothetv
• Migwel
• Kozan
• IndyKCrew
StarCraft: Brood War
• HerbMon 41
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota21809
League of Legends
• Doublelift5154
• imaqtpie2982
• Scarra635
• Lourlo347
Upcoming Events
Replay Cast
23h 31m
Wardi Open
1d 11h
WardiTV Invitational
2 days
Replay Cast
2 days
The PondCast
3 days
WardiTV Invitational
3 days
Replay Cast
3 days
uThermal 2v2 Circuit
6 days
Liquipedia Results

Completed

Proleague 2026-01-31
HSC XXVIII
Underdog Cup #3

Ongoing

CSL 2025 WINTER (S19)
KCM Race Survival 2026 Season 1
Acropolis #4 - TS4
Rongyi Cup S3
Nations Cup 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8

Upcoming

Escore Tournament S1: W7
Escore Tournament S1: W8
Acropolis #4
IPSL Spring 2026
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
LiuLi Cup: 2025 Grand Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 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.