提交时间:2023-05-20 17:22:40
运行 ID: 74181
#include<bits/stdc++.h> using namespace std; long long n,ans=10000000000000; long long d[10]={6,2,5,222,4,222,6,3,7,222};//3,5,9不选 void b(long long x){ if(x==3) cout<<'7'; else if(x%2==1){ cout<<'7'; for(long long i=1;i<=(x-3)/2;i++){ cout<<'1'; } } else{ for(long long i=1;i<=x/2;i++){ cout<<'1'; } } return; } void sa(long long x,long long s){ if(x==1) return; else if(x==0){ ans=min(ans,s); return; } else if(x<0) return; else if(s>=ans) return; for(long long i=0;i<=9;i++){ if(i!=3&&i!=5&&i!=9){ if(s==0&&i==0) continue; sa(x-d[i],s*10+i); } } return; } int main(){ cin>>n; sa(n,0); cout<<ans; cout<<" "; b(n); return 0; }