/****************************************************
* 2012/06/25 *
* AOJ Volume11 1154 Monday-Saturday Prime Factors *
* wrote crane *
*****************************************************/
#include<iostream>
#include<cmath>
using namespace std;
#define MAX_N 300000
int field[MAX_N];
bool res[MAX_N];
int main(){
int input;
while(cin >> input, input != 1){
cout << input << ":";
int a=0;
for(int i=6; i<MAX_N; i++) res[i] = 0;
field[a++] = 6; res[6] = 1;
for(int i=7; i<MAX_N; i+=7){
if(i+1<MAX_N){
field[a++] = i+1;
res[i+1] = 1;
}
if(i+6<MAX_N){
field[a++] = i+6;
res[i+6] = 1;
}
}
for(int i=0; i<a; i++)
for(int j=field[i]*2; j<MAX_N; j=j+field[i])
res[j] = 0;
for(int i=1; i<=input; i++)
if(res[i] == 1)
if(input % i == 0)
cout << " " <<i;
cout << "\n";
}
return 0;
}
0 件のコメント:
コメントを投稿