码迷,mamicode.com
首页 > 其他好文 > 详细

分析code

时间:2016-03-20 21:08:13      阅读:296      评论:0      收藏:0      [点我收藏+]

标签:

 1 using System;  //跟系统说明一下可能会用到这个dll里面的东西
 2 using System.Collections.Generic;  //引用集合类命名空间
 3 using System.Text;  //引入文本操作命名空间
 4    
 5 namespace FindTheNumber  //命名空间
 6 {  
 7      class Program  
 8      {  
 9           static void Main(string[] args)  //虚拟机调用程序入口
10           {  
11                int [] rg =                //定义30个数组
12                {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,  
13                18,19,20,21,22,23,24,25,26,27,28,29,30,31};  
14    
15                for(Int64 i = 1; i < Int64.MaxValue; i++)  //inter表示inter64位 范围最大为inter64.MaxValue=9,233,372,036,854,775,087 
16                {                                         //不能整除2~31的相邻2个数,却能整除其余的数
17                     int hit = 0;  
18                     int hit1 = -1;  
19                     int hit2 = -1;  
20                     for (int j = 0; (j < rg.Length) && (hit <= 2); j++)  //
21                     {  
22                           if((i % rg[j]) != 0)  
23                           {  
24                                hit++;  
25                                if(hit == 1)  
26                                {  
27                                     hit1 = j;  
28                                }  
29                                else if (hit == 2)  
30                                {  
31                                     hit2 = j;  
32                                }  
33                                else  
34                                     break;   
35    
36                           }  
37                     }  
38    
39                     if((hit == 2) && (hit1 + 1 == hit2))  
40                     {  
41                           Console.WriteLine("found {0}", i);   //  占位符i的位置输给found{0} 
42                     }  
43    
44                }  
45           }  
46      }  
47 }   

1.是不能整除2至31的相邻两个数却能整除其他所有数的数

2.存在。。。2*2*2*3*3*3*5*5*7*11*13*19*23*29*31=2123581660200

3. 2min

4.使用多线程分别运行其中的一部分将会提高好几倍

分析code

标签:

原文地址:http://www.cnblogs.com/menghuide/p/5299405.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!