题解:P11568 一维数组

· · 题解

思路

只要输出 n1m1 即可。理由如下。

设一个数(若干个 1)为 10^{a}+10^{a-1}+…+10^0,另一个数(若干个 1)为 10^{b}+10^{b-1}+…+10^0

nm=(10^a+10^{a-1}+10^{a-2}+…+10^0)(10^b+10^{b-1}+10^{b-2}+…+10^0)

=10^{a+b}+10^{a+b-1}+…10^a+10^{a+b-1}+10^{a+b-2}+…+10^{a-1}+…10^b+10^{b-1}+…10^0 =10^{a+b}+2\times 10^{a+b-1}+3\times 10^{a+b-2}+…+3\times 10^2+2\times 10^1+10^0 ## 代码 ```cpp #include<iostream> using namespace std; int main(){ int n,m; cin>>n>>m; while(n--) cout<<1; cout<<" "; while(m--) cout<<1; }