Problem A
分情況討論:
- 如果
并且
,那么說明不存在合法的劃分方案,輸出NO。
- 否則,只需要把第一個(gè)字母劃出來作為一個(gè)單獨(dú)的數(shù)字,其他的作為另一個(gè)數(shù)字即可。
時(shí)間復(fù)雜度為
#include <iostream>
#include <string>
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
小范圍打表可以發(fā)現(xiàn):
于是可以得出答案為
時(shí)間復(fù)雜度為
#include <iostream>
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;
}