【Codeforces】Educational Codeforces Round #59

Problem A

分情况讨论:

  • 如果并且,那么说明不存在合法的划分方案,输出NO。
  • 否则,只需要把第一个字母划出来作为一个单独的数字,其他的作为另一个数字即可。

时间复杂度为

#include 
#include 

using namespace std;

int main()
{
    int q;
    cin >> q;
    while(q--)
    {
        int n;
        cin >> n;
        string s;
        cin >> s;

        if((n == 2) && (s[0] >= s[1]))
        {
            cout << "NO" << endl;
        }
        else
        {
            cout << "YES" << endl;
            cout << 2 << endl;
            s.insert(s.begin() + 1, ' ');
            cout << s << endl;
        }
    }
    return 0;
}

Problem B

小范围打表可以发现:

于是可以得出答案为

时间复杂度为

#include 

using namespace std;

typedef long long LL;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        LL k, x;
        cin >> k >> x;
        cout << (k - 1) * 9 + x << endl;
    }
    return 0;
}

后续待补充

你可能感兴趣的:(【Codeforces】Educational Codeforces Round #59)