切木棍 题解(找规律,三目运算符):
#include<bits/stdc++.h>
using namespace std;
void judege(int n){
if(n % 2 != 0){ cout << 0 << endl; return; } // 若长度为偶数则无法组成矩形
cout << ((n % 4 == 0) ? (n / 4 - 1) : (n / 4)) << '\n';
}
int main(){
int n;
while(cin >> n) judege(n);
return 0;
}
登录后发布评论
暂无评论,来抢沙发