+ 2
Help. Are you capable of solving this program?
Can you write a program to find the number of ordered 64-tuples {a1,a2,...,a64} such that a1,a2,...,a64 are distinct elements of {1,2,...,2017} and a1+a2+...+a64 is divisible by 2017? Note: this problem is really hard to solve without computers.
7 ответов
+ 1
Well that would be difficult, to generate variables, I don't know, if there is a module for it, but I suggest rather to use dictionaries, than you would do that with variables, you would do that by strings as keys of dictionaries, i'll give you a code very soon.
+ 1
I Can offer a simple solution to the problem without a program:
{a1=1, a2=2 .. a32=32, a33=1984, a34=1985.. a64=2016}
So:
a1+a64 = a2+a63 = ... = 2017
The elements are different and sum up to 67424 which is 2017x32 so it's divisible by 2017.
Am I missing something? It was too easy... Probably won't be too hard to write a program using that algorithm (in case my answer is right)
+ 1
Jack ,you found one tuple that satisfies the conditions, but the problem is to find how many tuples there are, you better write a program :D
0
Dictionary = {}
for i in range(2017):
Dictionary["a" + str(i + 1)] = i
print(Dictionary)
0
I can't run it here either, but, where does it take in to account the part "a1+a2+... +a64 is divisible by 2017"?
0
#Defines some functions.
def AB(C, D):
if sum(C) != 0:
if D % sum(C) == 0:
print(sum(C))
#Takes a value, which will be divided by numbers from 0 to 63.
Value = 2017
Range = list(range(64))
#Indexes Range by 64! different ways!
A = 0
B = 0
while True:
while True:
AB(Range[A:B], Value)
B += 1
if B >= 63:
B = 0
break
A += 1
if A >= 63:
break
0
Heisenberg
Yeah, it's really a hard problem.
I got a headache while thinking of a solution which won't go through the 9x10^121 options of choosing a subset of 64 elements out of 2017 elements.