级数 A 遵循此规则:
每个值是所有奇数加在一起,包括 N sub i 。
N 子 4。
1+3+5+7 = 16
进阶 B 遵循此规则。取平方根乘以 2 加 1 的上限。从天花板尖齿本身中减去 N。继续添加奇数。
N = 33。
天花板(√33)=6。
6*2+1=13。
36-33=3。
3+13 =16。
停止,因为 16 在进程 A 和 B 中。是否有可能快速做到这一点?即最小的 1 或 2 步解决方案?java或通用实现会很方便
*问题*
What is the output you desire? Simply abool saying they do meet? Or do you want the indices at which they do meet, i.e.A[4]=16 andB[17]=16? Or do you just want the number at which they meet, i.e.16? And what if they don't meet exactly? Do you want the indices (or number) before, or after, the intersection? Finally, when or how do you decide to halt, if, say, the two sequences will never meet? (I know in this case they do, but I mean in the general case.)
我期望的输出将是值 16 或者它可能是 B 找到该值的索引,因为两者都是等价的,因为索引只是第 i 项。如果他们不见面,我意识到这是一个非终止程序。这种情况我不在乎。