sgu 141 分类: sgu 2015-03-16 19:36 39人阅读 评论(0) 收藏


暴力


#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<iostream>
#include<algorithm>

const int SIZE = 40000;

long long x,y,k,p;
bool flag = false;

int main()
{
#ifndef ONLINE_JUDGE
    freopen("sgu141.in","r",stdin);
    freopen("sgu141.out","w",stdout);
#endif

    std::cin >> x >> y >> p >> k;

    for(int a = -SIZE; a <= SIZE ; a++)
    {
        if((p-a*x)%y)continue;

        int b = (p-a*x)/y;

        if((a+b+k)%2)continue;

        int c = (a+b+k)/2;

        if(std::max(a,0)<=std::min(c,c-b))
        {
            long long p1 = std::max(a,0),p2 = c - p1,n1 = p1 - a,n2 = c - b - p1;

            puts("YES");  std::cout<< p1 << " " << n1 <<" " <<  p2 << " " << n2;
            flag = true;   break; 
        }
    }

    if(flag == false)puts("NO");


#ifndef ONLINE_JUDGE        
    fclose(stdin);
    fclose(stdout);
#endif  
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

posted @ 2015-03-16 19:36  <Dash>  阅读(181)  评论(0)    收藏  举报