Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
18337 hhz123 [acwing]找数字 C++ 通过 0 MS 256 KB 573 2023-02-19 11:11:47

Tests(10/10):


#include <bits/stdc++.h> using namespace std; int m,s; int a[110],b[110]; int main(){ cin>>m>>s; int s1=s,s2=s; if((s==0&&m>1)||s>m*9)cout<<"-1 -1"; else{ for(int i=1;i<=m;i++){ if(s1>9){ a[i]=9; s1-=9; }else { a[i]=s1; s1=0; } } for(int i=m;i>=1;i--){ b[m-i+1]=a[i]; } if(b[1]==0){ for(int i=1;i<=m;i++){ if(b[i]>0){ b[i]-=1; break; } } b[1]=1; } for(int i=1;i<=m;i++){ cout<<b[i]; } cout<<' '; for(int i=1;i<=m;i++){ cout<<a[i]; } } return 0; }


测评信息: