Openjudge 1.13-21: Maximum mass factor sequence (two water per day)

Source: Internet
Author: User

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.

    • View
#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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.