|  | 
|  | 
| вернуться в форум | get WA at test 41 Послано Fahim  1 дек 2023 18:13#include<bits/stdc++.h>using namespace std;
 bool isPrime(int n)
 {
 if(n!=2&&n%2==0)return false;
 if(n<2)return false;
 for(int i=3;i<=sqrt(n);i+=2)
 {
 if(n%i==0)return false;
 }
 return true;
 }
 int main()
 {
 int n;
 cin>>n;
 int x=9,r;
 if(n==1)cout<<1<<endl;
 else if(n==0)cout<<10<<endl;
 else{
 vector<int>v;
 while(1)
 {
 if(n%x==0)
 {
 if(isPrime(n)==true)
 {
 if(n>9){cout<<-1<<endl;return 0;}
 }
 n=n/x;
 if(x==1)break;
 v.push_back(x);
 }
 else
 {
 x--;
 }
 
 }
 for(int i=v.size()-1;i>=0;i--)
 {
 cout<<v[i];
 }
 cout<<endl;
 }
 }
 | 
 | 
|