Super Snooker

来源:互联网 发布:淘宝隐形降权怎么查询 编辑:程序博客网 时间:2024/04/30 19:05
#include <iostream>using namespace std;int main() {    int t;    cin>>t;    int a,b,c,d;    for (int i=1;i<=t;i++) {        cin>>a>>b>>c>>d;        int s=(c+d)*(d-c+1)/2;        int len = d-c+1;        if(a>b) swap(a,b);        if((a+b+s)%2==1||(b+s-a)%2==1||b>a+s) {            cout<<"not possible"<<endl;            continue;        }            int flag = 0;        for (int j=0;j<=len;j++) {            int _min=(c+c+j-1)*j/2;            int _max=(d+d-j+1)*j/2;            int x = (b+s-a)/2;            if (x>=_min&&x<=_max) {                cout<<"possible"<<endl; flag = 1;                break;            }        }        if(!flag)         cout<<"not possible"<<endl;    }}
0 0
原创粉丝点击