K. Divisors
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
--------------------------------------------------------------------------------------------------------------------------------
Given a number N. Print all the divisors of N in ascending order.
Input
Only one line containing a number N (1 ≤ N ≤ 104).
Output
Print all positive divisors of N, one number per line.
Examples
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
if(n%i==0)
{
cout<<i<<endl;
}
break;
}
}
return 0;
}
*******************************************************
No comments:
Post a Comment