uva993 - Product of digits-------------水题 1A
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>#include <cmath>#define N 105using namespace std;int n;int a[10];int main(){// freopen("ex.in","r",stdin); int t; scanf("%d",&t); while(t--) { memset(a,0,sizeof(a)); scanf("%d",&n); if(n<=9) { printf("%d\n",n); continue; } int i=9; while(i>=2) { if(n%i) i--; else { a[i]++; n/=i; } } if(n!=1) { printf("-1\n"); } else { for(int i=2; i<=9; i++) { for(int j=0; j<a[i]; j++) printf("%d",i); } printf("\n"); } } return 0;}