[Archive!] Pure mathematics, physics, chemistry, etc.: brain-training problems not related to trade in any way - page 321

 
Mathemat >>:

Вариантов нет. Для 30 знаков нужно как-то эффективно ограничивать перебор.

Рекурсию, наверно, бесполезно (если число знаков больше 10).

Yes, I agree. Started to write and immediately realised that long would simply overflow.

// But I don't expect any problems with stack at 30 (or even 300) digits.

I've already found an iterative (in one loop) way, but... the bit size of the product is not enough anyway.

 
MetaDriver писал(а) >>

Yes, I agree. I started writing and immediately understood that the long will simply overflow.

And we don't need recursion, it could be simpler, I've already found iterative (in one loop) way, but... the bit depth per product is not enough anyway.


Long should be changed to String, as silly as it may sound.

 
Richie >>:


Long нужно на String менять, как бы глупо это не звучало.

It doesn't sound too stupid, just multiplication and addition will have to be rewritten by hand.

It's fine, but the speed will go in the sand, and for 30-digit numbers it will take a long time to count.

// True, it's still an order or two faster on mcl5 than on Wasik :-P

 
What's this got to do with long? It's all about numbers. Yeah, I know, you want to cram everything into one loop. Try extracting the 17th digit from the left side of a 30-digit number.
Each number is an array or a string of digits. Increasing a number is a manual modeling task.
It's a long time anyway, the collider will work faster :)
 
Conclusion - we need a different algorithm, NOT overkill. Or Intelligent Search.
For example, it is clear that we need to search just sets of digits, and the fact that these numbers put in a row can form some number for the problem is not important.
Further - if the sum of numbers is a prime number - is skipped.
And so on.
 
Mathemat >>:
А при чем тут лонг? Тут же исключительно с цифирями работа. Ну да, понимаю, хоцца все в один цикл всунуть. Дык попробуй-ка 17-ю цифру слева у 30-разрядного числа быстро извлечь.

Long with the product of 30 numbers averaging 5 == 5^30

// ~ == 9.31323E+20 (and the long fits a maximum of 15 decimal places)

;)

 
MetaDriver >>:
Вожусь немножко с №226.
Вьехал, что точки лежат не только на окружностях с центром в точке == центру многоугольника,
но и на наборе окружностей "половинного" диаметра прижатых к краям 1976-угольника.
Это легко понять, если представить себе место середин точек всех хорд пересекающих окружность одним из своих концов в фиксированной точке.
Возможно на этих окружностях лежат ещё какие-то "полуточки". (с) Т.е. ответ будет возможно больше чем очевидный минимум (1976).
Думаю дальше.
// Кстати, 1976 == 2*2*2*13*19
// Не знаю поможет ли это делу. Но во внимание принимаю. :)

I think the answer can't be more than 1976. but the evidence is still hard to come by.

 
One fact from Cohen's book on Diophantine equations:

This representation of 30 as a sum of three cubes was not known until recently (this is the first solution found for the number 30; the representation of 30 by three cubes has long been a hypothesis). Found, of course, on a computer. The order of the numbers (already cubes) is just about 30 digits.
It is unlikely to have been done by dumb brute force.
 
Richie >>:

Вот сама программка:
-
'Объява
Dim M As Long
Dim N As Long
Dim Koeficient As Long

Private Sub Command1_Click()
Dim MaxChislo As Long
Dim MinChislo As Long
Dim i As Long
Dim strok As String
'Задаём исходные данные
MinChislo = 1
MaxChislo = 100000
Koeficient = 128
For i = MinChislo To MaxChislo
strok = LTrim(RTrim(Str(i)))
If ProizCifr(strok) / SumCifr(strok) = Koeficient Then
Print strok
Else
'Print "Ни фига не найдено"
End If
Next i
End Sub

'РАСЧЁТ СУММЫ
Private Function SumCifr(Stroca As String) As Long
Dim i As Long
Dim Summa As Long
Dim Cifra As Long
For i = 1 To Len(Stroca)
Cifra = Val(Mid(Stroca, i, 1))
Summa = Summa + Cifra
Next i
SumCifr = Summa
End Function

'РАСЧЁТ ПРОИЗВЕДЕНИЯ
Private Function ProizCifr(Stroca As String) As Long
Dim i As Long
Dim Proiz As Long
Dim Cifra As Long
Proiz = 1
For i = 1 To Len(Stroca)
Cifra = Val(Mid(Stroca, i, 1))
Proiz = Proiz * Cifra
Next i
ProizCifr = Proiz
End Function

No way...
And this is what a perl algorithm looks like:


for(111..999){
split(//,$_);
my($sum,$mul)=(0,1);
for(@_){$sum+=$_;$mul*=$_;}
print("$_\n") if($sum*12==$mul);
}

 
admin >>:

Ни фига себе..
А вот как выглядит алгоритм на perl:

.....


He's just a programmer.... not so much.

I can do it in four or five lines in Wasik.

:)

Reason: