'commit'
This commit is contained in:
23
TangDou/XiTi/1315_3.cpp
Normal file
23
TangDou/XiTi/1315_3.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
int n, m;
|
||||
int ans;
|
||||
int main() {
|
||||
cin >> n >> m;
|
||||
//出发点特判
|
||||
if (n == 1 && m == 1) {
|
||||
puts("1");
|
||||
return 0;
|
||||
}
|
||||
//奇偶行分类,然后n = m特判
|
||||
//如果n是奇数
|
||||
if (n & 1) {
|
||||
ans = n + m - 1;
|
||||
if (n == m) ans--;
|
||||
} else // n是偶数
|
||||
ans = n + (m - 1) / 2 * 2;
|
||||
|
||||
printf("%d", ans);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user