提交时间:2026-04-16 11:56:29
运行 ID: 316672
#include<bits/stdc++.h> #define lc p<<1 #define rc p<<1|1 #define ll long long #define spp(a) sort(a.begin(),a.end()) #define pll pair<ll,ll> #define mll map<ll,ll> #define ff first.first #define fs first.second #define sf second.first #define ss second.second #define eps 1e-6 double pi=3.14159265; //#define endl '\n' #define l128 __ll128 using namespace std; ll mod = 998244353; //template<typename U,typename V>U min(U x,const V y){return x<y?x:y;}; //template<typename U,typename V>U max(U x,const V y){return x>y?x:y;}; template<typename U,typename V>bool cmin(U &x , const V y){ return x>y?x=y,1:0;} template<typename U,typename V>bool cmax(U &x , const V y){ return x<y?x=y,1:0;} bool ifsu(ll x) { if (x == 1)return 0; for (ll i = 2; i <= sqrt(x); i++) { if (x % i == 0) { return 0; } } return 1; } ll gcd(ll x, ll y) { return y == 0 ? x : gcd(y, x % y); } ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } ll qpow(ll x,ll n){ll ans=1;for(;n;n>>=1,x*=x,x%=mod)if(n&1)ans*=x,ans%=mod;return ans;} template<typename U,typename V>U qpow(U x,V n){U y(1);for(;n;n>>=1,x*=x)if(n&1)y*=x;return y;} struct ml{ ll x; ml():x(){} template<typename T>ml(T x):x((x%=mod)<0?x+mod:x){} ml inv()const{return qpow(*this,mod-2);} ml operator-()const{return ml(-x);} ml &operator+=(const ml &t){return (x+=t.x)<mod?0:x-=mod,*this;} ml &operator-=(const ml &t){return (x-=t.x)<0?x+=mod:0,*this;} ml &operator*=(const ml &t){return x=(ll)(x)*t.x%mod,*this;} ml &operator/=(const ml &t){return *this*=t.inv();} operator ll()const{return x;} bool operator==(const ml &t)const{return x==t.x;} template<typename T>ml operator+(const T &t){return ml(*this)+=t;} template<typename T>ml operator-(const T &t){return ml(*this)-=t;} template<typename T>ml operator*(const T &t){return ml(*this)*=t;} template<typename T>ml operator/(const T &t){return ml(*this)/=t;} template<typename T>friend ml operator+(const T &x,const ml &y){return ml(x)+=y;} template<typename T>friend ml operator-(const T &x,const ml &y){return ml(x)-=y;} template<typename T>friend ml operator*(const T &x,const ml &y){return ml(x)*=y;} template<typename T>friend ml operator/(const T &x,const ml &y){return ml(x)/=y;} friend istream &operator>>(istream &is,ml &t){ll x;is>>x;t=ml(x);return is;} friend ostream &operator<<(ostream &os,const ml &t){return os<<t.x;} }; void ji(){ ll n; cin>>n; string s="1"; for(ll i=0;i<n-1;i++){ ll flag=0; for(ll j=s.size()-1;j>=1;j--){ if(s[j]!='9'&&s[j]+1-s[j-1]<=1){ s[j]++; for(ll k=j+1;k<s.size();k++){ s[k]=max(char(s[k-1]-1),'0'); } flag=1; break; } } if(flag)continue; if(s[0]=='9'){ for(auto &x:s)x='0'; s='1'+s; }else{ s[0]++; for(ll k=1;k<s.size();k++){ s[k]=max(char(s[k-1]-1),'0'); } } } cout<<s<<endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); ll t=1; //cin>>t; for(ll i=1;i<=t;i++)ji(); return 0; } /* 1 8 3 0 -2 1 2 -2 3 -3 */