简单题,直接分解出每个数的因子,然后从小到大逐一输出即可。
Run Time: 0sec
Run Memory: 304KB
Code length: 493Bytes
Submit Time: 2011-12-10 15:15:15
// Problem#: 2001
// Submission#: 1059629
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <cstdio>
using namespace std;
int main()
{
int P, Q;
int i, j;
int n = 0, m = 0;
int F1[ 6000 ], F2[ 6000 ];
scanf( "%d%d", &P, &Q );
for ( i = 1; i <= P; i++ ) {
if ( P % i == 0 )
F1[ n++ ] = i;
}
for ( j = 1; j <= Q; j++ ) {
if ( Q % j == 0 )
F2[ m++ ] = j;
}
for ( i = 0; i < n; i++ ) {
for ( j = 0; j < m; j++ )
printf( "%d %d\n", F1[ i ], F2[ j ] );
}
return 0;
}