标签:
1 /// <summary> 2 /// Solution 3 /// 通过率 100/50 4 /// </summary> 5 /// <param name="N"></param> 6 /// <param name="M"></param> 7 /// <returns></returns> 8 public int solution(int N, int M) 9 { 10 bool[] flagArr = new bool[N]; 11 int index = 0; 12 int result = 0; 13 while (true) 14 { 15 if (flagArr[index] == true) 16 return result; 17 else 18 { 19 flagArr[index] = true; 20 result++; 21 index = (index + M) % N; 22 } 23 } 24 return 0; 25 }
标签:
原文地址:http://www.cnblogs.com/HuoAA/p/4677006.html