最小公倍数
时间限制: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
//打表 import java.math.BigDecimal; import java.math.BigInteger; import java.util.Scanner; public class Main{ public static void main(String args[]){ Scanner cin = new Scanner(System.in); /*final int MAX = 105; int arr[] = new int[MAX]; BigInteger res[] = new BigInteger[MAX]; for(int i=1; i<MAX; ++i)arr[i] = i; for(int i=2; i<MAX; ++i){ for(int j=i+1; j<MAX; ++j){ if(j%i == 0) arr[j] /= arr[i]; } } for(int i=1; i<MAX; ++i)res[i] = BigInteger.ONE; for(int i=2; i<MAX; ++i){ for(int j=2; j<i; ++j){ res[i] = res[i].multiply(BigInteger.valueOf(arr[j])); } } for(int i=1; i<101; ++i){ int n = i; System.out.println("\""+res[n+1] + "\","); }*/ String s[] = { "1", "2", "6", "12", "60", "60", "420", "840", "2520", "2520", "27720", "27720", "360360", "360360", "360360", "720720", "12252240", "12252240", "232792560", "232792560", "232792560", "232792560", "5354228880", "5354228880", "26771144400", "26771144400", "80313433200", "80313433200", "2329089562800", "2329089562800", "72201776446800", "144403552893600", "144403552893600", "144403552893600", "144403552893600", "144403552893600", "5342931457063200", "5342931457063200", "5342931457063200", "5342931457063200", "219060189739591200", "219060189739591200", "9419588158802421600", "9419588158802421600", "9419588158802421600", "9419588158802421600", "442720643463713815200", "442720643463713815200", "3099044504245996706400", "3099044504245996706400", "3099044504245996706400", "3099044504245996706400", "164249358725037825439200", "164249358725037825439200", "164249358725037825439200", "164249358725037825439200", "164249358725037825439200", "164249358725037825439200", "9690712164777231700912800", "9690712164777231700912800", "591133442051411133755680800", "591133442051411133755680800", "591133442051411133755680800", "1182266884102822267511361600", "1182266884102822267511361600", "1182266884102822267511361600", "79211881234889091923261227200", "79211881234889091923261227200", "79211881234889091923261227200", "79211881234889091923261227200", "5624043567677125526551547131200", "5624043567677125526551547131200", "410555180440430163438262940577600", "410555180440430163438262940577600", "410555180440430163438262940577600", "410555180440430163438262940577600", "410555180440430163438262940577600", "410555180440430163438262940577600", "32433859254793982911622772305630400", "32433859254793982911622772305630400", "97301577764381948734868316916891200", "97301577764381948734868316916891200", "8076030954443701744994070304101969600", "8076030954443701744994070304101969600", "8076030954443701744994070304101969600", "8076030954443701744994070304101969600", "8076030954443701744994070304101969600", "8076030954443701744994070304101969600", "718766754945489455304472257065075294400", "718766754945489455304472257065075294400", "718766754945489455304472257065075294400", "718766754945489455304472257065075294400", "718766754945489455304472257065075294400", "718766754945489455304472257065075294400", "718766754945489455304472257065075294400", "718766754945489455304472257065075294400", "69720375229712477164533808935312303556800", "69720375229712477164533808935312303556800", "69720375229712477164533808935312303556800", "69720375229712477164533808935312303556800", }; while(cin.hasNext()){ int n = cin.nextInt(); System.out.println(s[n-1]); } } }