这题其实我不会,随便找了几个特例算算觉得答案可能是(n-1)/2就打了交,居然过了。可是不太理解这种做法的正确性,上网搜一下,也没人写解题报告,改天问问老师去……
/* * hdu1273/win.cpp * Created on: 2012-10-23 * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <ctime> #include <iostream> #include <algorithm> #include <queue> #include <set> #include <map> #include <stack> #include <string> #include <vector> #include <deque> #include <list> #include <functional> #include <numeric> #include <cctype> using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("data.in", "r", stdin); #endif int N; while(scanf("%d", &N) == 1 && N != 0) { printf("%d\n", (N - 1) / 2); } return 0; }