-
Total time limit:
-
1000ms
-
Memory Limit:
-
65536kB
-
-
Describe
-
-
Any input two positive integers m, n (1 < m < n <= 5000), and sequentially outputs the maximum mass factor (including M and N) for each number between M and N, and if a number itself is a prime number, the output is itself.
-
-
Input
-
A
-
row that contains two positive integers m and n, with a single space interval.
-
-
Output
-
One
-
row, the maximum quality factor for each integer, separated by commas.
-
-
Sample input
-
-
5 10
-
-
Sample output
-
-
5,3,7,2,3,5
-
or a water problem.
#include <iostream>#include<cstring>#include<cstdio>#include<cmath>using namespacestd;intans[100010];intm,n,i,j,h;intPdintk) { for(intL=2; l<=sqrt (k); + +l)if(k%l==0)return 0; return 1;}intMain () {BOOLFlag; Ios::sync_with_stdio (false); CIN>>m>>N; for(i=m;i<=n;++i) { for(j=i;j>=2;--j) { if(i%j==0){ if(PD (j)) {Ans[h++]=J; Break; } } } } for(i=0; ii) {if(i==0) cout<<Ans[i]; Elsecout<<","<<Ans[i]; } return 0;}
Openjudge 1.13-21: Maximum mass factor sequence (two water per day)