提交时间:2023-05-23 21:49:42

运行 ID: 74425

#include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <algorithm> #include <string> #include <cstring> #include <map> #include <vector> #include <set> using namespace std; long long dp[105]; int f[15],n; int main() { freopen("stick.in","r",stdin); freopen("stick.out","w",stdout); f[1]=2; f[2]=5; f[3]=5; f[4]=4; f[5]=5; f[6]=6; f[7]=3; f[8]=7; f[9]=6; f[0]=6; dp[2]=1; dp[3]=7; dp[4]=4; dp[5]=2; dp[6]=6;dp[7]=8; for (int i=8; i<=100; i++) { dp[i]=dp[i-f[0]]*10; for (int j=0; j<=9; j++){ if (dp[i-f[j]]!=0) dp[i]=min(dp[i],dp[i-f[j]]*10+j); } cin>>n; cout<<dp[n]<<' '; if (n%2==1) { cout<<7; n-=3; } while (n){ cout<<1; n-=2; } return 0; }