这道题我们经过简单的推测便可得知3个之前特判,四个之后就成为了一般状况,就是我们每侧都是走整个整个的|_|之后零的走|||。
考试的时候包括平时做题,许多正确的感性比理性证明要强得多。
#include <cstdio> using namespace std; int main() { int n,m; scanf("%d%d",&n,&m); if(n==0||m==0) { printf("impossible"); return 0; } if(n==1&&m==1) { printf("0"); return 0; } if(n<=2) { if((m-1)%3!=0) { printf("impossible"); return 0; } printf("%d",(m-1)/3*2+n-1); return 0; } if(n==3) { if(m==3) { printf("8"); return 0; } printf("%d",(m-1)/3*2+2+(m-1)%3+((m-1)%3==0?0:2)); return 0; } printf("%d",(n-1)/3*2+(n-1)%3+(m-1)/3*2+(m-1)%3); return 0; }