Sidecases, what to report?

Sidecases, what to report?

From the example case

sum(17:19) = 36 = 6**2
sum(5:13) = 36 = 6**2

I'm able to tell that if several sequences produce the same sum they all have to be reported, but how do we handle duplicates on the power side of things?

for instance:

sum(20063:32987) and sum(2097031:2097287) both produce 33554432 (frist draft of my app, results could be wrong) no problem just report both lines, yet 33554432 gives an interesting sidecase being both 2^25 and 32^5.

Do we just pick one? if so which one should we pick? does it matter? do we pick both? if so how do we report?

like this

sum(20063:32987)=33554432=2**25=32**5
sum(2097031:2097287)=33554432=2**25=32**5

or like this:

sum(20063:32987)=33554432=2**25
sum(20063:32987)=33554432=32**5
sum(2097031:2097287)=33554432=2**25
sum(2097031:2097287)=33554432=32**5

Also note this problem is not limited to 2 duplicates, for instance sum(7063741:7064419) gives us 268435456 which I can make out of 2^28, 4^14, 16^7 and 128^4

Please advise.

10 帖子 / 0 全新
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项

As per problem statement we need to write only that case where the maximum power is 6.
so as per my understanding 2**25 is not eexpected as output.

You misunderstood, the power of 6 is used as an example given as a parameter, the rules state all numeric parameters are 32 bit unsigned integers so intel is free to give us puzzles that search up to a maximum power of 4294967296.

Hi,
You have a good point on the power side. But from the examples you indicated, I do not see any value add in reporting multiple right-hand-side power equivalents. To keep it simple, we would want you to report 1 RHS entry.

Thanks
-Rama

Hi Rama

If I understood you, it means sum(X:Y) should not be repeated for same X & Y(irrespective of powers) i.e. LHS should be unique in output.

Quoting hitesh.sharmaHi Rama

If I understood you, it means sum(X:Y) should not be repeated for same X & Y(irrespective of powers) i.e. LHS should be unique in output.

Yes, that is right. Have 1 pair of sum(X:Y) = base ^exponent.

Thanks
-Rama

Quoting lazydodo
Also note this problem is not limited to 2 duplicates, for instance sum(7063741:7064419) gives us 268435456 which I can make out of 2^28, 4^14, 16^7 and 128^4

FYI, there's one more duplicate in this example: 268435456 = 16384^2

This would be the one to report if maximum power m is 2 or 3.

- Rick

Thus reporting these two would be overkill:

sum(523:839)=32768=32**3
sum(523:839)=32768=2**15

And only:

sum(523:839)=32768=32**3

is required when specified: 523 839 15?

Yes that is correct. Not sure how they will handle people reporting multiple though, its not in the 'official rules' that you should only report one and they can't expect everyone to be checking the forums.

Right,outputting both results may result in extra cpu cycles. So... shame for who will implement this!

发表评论

登录添加评论。还不是成员?立即加入