Codeforces 584 A.Olesya and Rodion

Codeforces 584A A.Olesya and Rodion
在这里插入图片描述
思路分析:
一个小思维题,当 t < 10 时,输出 n 个 t 即可
要单独考虑的是 t =10
注意一下输出 -1 的特殊情况( n == 1 && t == 10 )

AC代码:

#include <iostream>

using namespace std;

int main() {
    
    
    int n,t;
    while (cin >> n >> t) {
    
    
        if( t < 10) {
    
    
            for(int i = 0;i<n;i++)
                cout << t;
        } else {
    
    
            if( n == 1)
                cout << -1;
            else {
    
    
                cout << 1;
                for(int i = 1;i<n;i++)
                    cout << 0;
            }
        }
        cout << endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_45654671/article/details/112727347