Files
python/TangDou/Dfs/DFS_1.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

23 lines
446 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}