ACM模版
题目

代码
using namespace std
const int MAXN = 1e4 + 10
const int MAXM = 1e3 + 10
char strs[MAXN]
char str[MAXM]
stack<string> ss
int main()
{
while (gets(str) != NULL)
{
strcat(strs, str)
}
string _str(strs, strlen(strs))
int len = (int)_str.size()
for (int i = 0
{
if (_str[i] == '<' && _str[i + 1] != '!' && _str[i + 1] != '/')
{
int j = i + 1
for (
{
if (_str[j] == '>')
{
break
}
}
string tmp = _str.substr(i + 1, j - 1 - i)
ss.push(tmp)
i = j + 1
}
else if (_str[i] == '<' && _str[i + 1] == '/')
{
int j = i + 2
for (
{
if (_str[j] == '>')
{
break
}
}
string tmp = _str.substr(i + 2, j - 2 - i)
if (0 != strcmp(tmp.c_str(), ss.top().c_str()))
{
cout << "Invalid"
return 0
}
else
{
ss.pop()
i = j + 1
}
}
else
{
i++
}
}
if (ss.empty())
{
cout << "Valid"
}
else
{
cout << "Invalid"
}
return 0
}
题目

代码
using namespace std
bool isrc(string &s)
{
if (s.size() < 2)
{
return false
}
if (!(s[0] == 'R' && isdigit(s[1])))
{
return 0
}
int i = 1
while (i < s.size() && s[i] != 'C')
{
i++
}
if (i == s.size())
{
return 0
}
return 1
}
string int2str(int num)
{
string s = ""
while (num)
{
int i = num % 26
if (i == 0)
{
char c = 'Z'
s = c + s
num = num / 26 - 1
}
else
{
char c = 'A' + num % 26 - 1
num /= 26
s = c + s
}
}
return s
}
string rc2(string &rc)
{
string ans = " "
int i = 1
while (rc[i] != 'C')
{
i++
}
int col = atoi(rc.substr(i + 1).c_str())
string s = int2str(col)
s += rc.substr(1, i - 1)
return s
}
string fun(int num)
{
string s = ""
while (num)
{
char c = '0' + num % 10
s = c + s
num /= 10
}
return s
}
string i2rc(string &s)
{
int i = 0
int col = 0
while (!isdigit(s[i]))
{
col = col * 26 + (s[i] - 'A' + 1)
i++
}
string r = "R"
r += s.substr(i)
r += "C"
r += fun(col)
return r
}
int n
string rc, s
int main()
{
cin >> n
for (int i = 0
{
cin >> rc
if (isrc(rc))
{
s = rc2(rc)
}
else
{
s = i2rc(rc)
}
cout << s << endl
}
return 0
}
题目

代码
using namespace std
typedef long long ll
ll solve (ll n, ll m, ll k)
{
ll l = 0, r = n * m + 1
while (r - l > 1)
{
ll mid = (l + r) / 2
ll cnt = 0
for (int i = 1
{
cnt += min (mid / i, n)
}
if (cnt >= k)
{
r = mid
}
else
{
l = mid
}
}
return r
}
ll n, m, k
int main ()
{
while (cin >> n >> m >> k)
{
cout << solve (n, m, k) << endl
}
return 0
}