A hot question recently (portal), seeing the discussions of Friends (Portal 1 portal 2), is scanning from 1 to 100, I want to talk about another idea.
This question can be converted into a card game for 100 people. what each person reports is what is written on the card.
Card issuance has a priority:
Those who have cards will not give them any more.
Assume that the three numbers are a, B, and c respectively. The priority is as follows:
It is better to calculate the minimum public multiples of less than 10, and do not need to scan from 1 to 100. It feels faster.
I made a comparison with the codes of young artists:
Source code (a little messy, more complex ):
Main (Test ([] s1 = str. split ([] s2 = [] {. parse (s1 []),. parse (s1 []),. parse (s1 [[] r1 = [] r2 = flag = (I =; I <; I ++ (r1 [I]! === (I =; I <; I ++ = DateTime. now-+ = (I =; I <; I ++ = DateTime. now-+ [] Test1 ([] result = [(I =; I <=; I ++-] = (I % a [] =? :) + (I % a [] =? :) + (I % a [] =? :) + (I % a []! = & I % a []! = & I % a []! = )? I. toString (): (I =; I <; I ++] * + I-] = result [I * + a []-] = [] Test2 ([] result = [(I =; I <; I ++] * + I-] = result [I * + a []-] =),], a []),], a [],], a []),], (I =; I <=; I ++ (. isNullOrEmpty (result [I--] = comp ([] result, temp, (I =; I * temp <=; I ++ (. isNullOrEmpty (result [I * temp-] = gcd (a, (a <a, (B = gcd (B, a % swap (, c = ngcd ([] a, (n =) a [gcd (a [n-], ngcd (a, n-lcm (, a * B/nlcm ([] a, (n = a [lcm (a [n-], nlcm (a, n-View Code
In addition, when one of the three numbers is an integer multiple of the other, you can optimize them!