• NYOJ--517--最小公倍数(大数打表)


    最小公倍数

    时间限制:1000 ms  |  内存限制:65535 KB
    难度:3
     
    描述
    为什么1小时有60分钟,而不是100分钟呢?这是历史上的习惯导致。
    但也并非纯粹的偶然:60是个优秀的数字,它的因子比较多。
    事实上,它是1至6的每个数字的倍数。即1,2,3,4,5,6都是可以除尽60。
     
    我们希望寻找到能除尽1至n的的每个数字的最小整数m.
     
    输入
    多组测试数据(少于500组)。
    每行只有一个数n(1<=n<=100).
    输出
    输出相应的m。
    样例输入
    2
    3
    4
    
    样例输出
    2
    6
    12
      1 //打表
      2 import java.math.BigDecimal;
      3 import java.math.BigInteger;
      4 import java.util.Scanner;
      5 public class Main{
      6     
      7     public static void main(String args[]){
      8         Scanner cin = new Scanner(System.in);
      9         /*final int MAX = 105;
     10         int arr[] = new int[MAX];
     11         BigInteger res[] = new BigInteger[MAX];
     12         for(int i=1; i<MAX; ++i)arr[i] = i;
     13         for(int i=2; i<MAX; ++i){
     14             for(int j=i+1; j<MAX; ++j){
     15                 if(j%i == 0)
     16                     arr[j] /= arr[i];
     17             }
     18         }
     19         for(int i=1; i<MAX; ++i)res[i] = BigInteger.ONE;
     20         for(int i=2; i<MAX; ++i){
     21             for(int j=2; j<i; ++j){
     22                 res[i] = res[i].multiply(BigInteger.valueOf(arr[j]));
     23             }
     24         }
     25         for(int i=1; i<101; ++i){
     26             int n = i;
     27             System.out.println("""+res[n+1] + "",");
     28         }*/
     29         String s[] = {
     30                 "1",
     31                 "2",
     32                 "6",
     33                 "12",
     34                 "60",
     35                 "60",
     36                 "420",
     37                 "840",
     38                 "2520",
     39                 "2520",
     40                 "27720",
     41                 "27720",
     42                 "360360",
     43                 "360360",
     44                 "360360",
     45                 "720720",
     46                 "12252240",
     47                 "12252240",
     48                 "232792560",
     49                 "232792560",
     50                 "232792560",
     51                 "232792560",
     52                 "5354228880",
     53                 "5354228880",
     54                 "26771144400",
     55                 "26771144400",
     56                 "80313433200",
     57                 "80313433200",
     58                 "2329089562800",
     59                 "2329089562800",
     60                 "72201776446800",
     61                 "144403552893600",
     62                 "144403552893600",
     63                 "144403552893600",
     64                 "144403552893600",
     65                 "144403552893600",
     66                 "5342931457063200",
     67                 "5342931457063200",
     68                 "5342931457063200",
     69                 "5342931457063200",
     70                 "219060189739591200",
     71                 "219060189739591200",
     72                 "9419588158802421600",
     73                 "9419588158802421600",
     74                 "9419588158802421600",
     75                 "9419588158802421600",
     76                 "442720643463713815200",
     77                 "442720643463713815200",
     78                 "3099044504245996706400",
     79                 "3099044504245996706400",
     80                 "3099044504245996706400",
     81                 "3099044504245996706400",
     82                 "164249358725037825439200",
     83                 "164249358725037825439200",
     84                 "164249358725037825439200",
     85                 "164249358725037825439200",
     86                 "164249358725037825439200",
     87                 "164249358725037825439200",
     88                 "9690712164777231700912800",
     89                 "9690712164777231700912800",
     90                 "591133442051411133755680800",
     91                 "591133442051411133755680800",
     92                 "591133442051411133755680800",
     93                 "1182266884102822267511361600",
     94                 "1182266884102822267511361600",
     95                 "1182266884102822267511361600",
     96                 "79211881234889091923261227200",
     97                 "79211881234889091923261227200",
     98                 "79211881234889091923261227200",
     99                 "79211881234889091923261227200",
    100                 "5624043567677125526551547131200",
    101                 "5624043567677125526551547131200",
    102                 "410555180440430163438262940577600",
    103                 "410555180440430163438262940577600",
    104                 "410555180440430163438262940577600",
    105                 "410555180440430163438262940577600",
    106                 "410555180440430163438262940577600",
    107                 "410555180440430163438262940577600",
    108                 "32433859254793982911622772305630400",
    109                 "32433859254793982911622772305630400",
    110                 "97301577764381948734868316916891200",
    111                 "97301577764381948734868316916891200",
    112                 "8076030954443701744994070304101969600",
    113                 "8076030954443701744994070304101969600",
    114                 "8076030954443701744994070304101969600",
    115                 "8076030954443701744994070304101969600",
    116                 "8076030954443701744994070304101969600",
    117                 "8076030954443701744994070304101969600",
    118                 "718766754945489455304472257065075294400",
    119                 "718766754945489455304472257065075294400",
    120                 "718766754945489455304472257065075294400",
    121                 "718766754945489455304472257065075294400",
    122                 "718766754945489455304472257065075294400",
    123                 "718766754945489455304472257065075294400",
    124                 "718766754945489455304472257065075294400",
    125                 "718766754945489455304472257065075294400",
    126                 "69720375229712477164533808935312303556800",
    127                 "69720375229712477164533808935312303556800",
    128                 "69720375229712477164533808935312303556800",
    129                 "69720375229712477164533808935312303556800",
    130         };
    131         while(cin.hasNext()){
    132             int n = cin.nextInt();
    133             System.out.println(s[n-1]);
    134         }
    135     }
    136 }
  • 相关阅读:
    ASP.NET大闲话:ashx文件有啥用
    Silverlight之我见——制作星星闪烁动画
    今天写了一个简单的新浪新闻RSS操作类库
    继续聊WPF——设置网格控件列标题的样式
    继续聊WPF——如何获取ListView中选中的项
    继续聊WPF——Thumb控件
    继续聊WPF——进度条
    继续聊WPF——自定义CheckBox控件外观
    继续聊WPF——Expander控件(1)
    继续聊WPF——Expander控件(2)
  • 原文地址:https://www.cnblogs.com/langyao/p/6775167.html
Copyright © 2020-2023  润新知