【Codeforces Round #451 (Div. 2) B】Proper Nutrition

【链接】 我是链接,点我呀:)
【题意】

在这里输入题意

【题解】

可以直接一层循环枚举。 也可以像我这样用一个数组来存y*b有哪些。 当然。感觉这样做写麻烦了。。

【代码】

/*
  	1.Shoud it use long long ?
  	2.Have you ever test several sample(at least therr) yourself?
  	3.Can you promise that the solution is right? At least,the main ideal
  	4.use the puts("") or putchar() or printf and such things?
  	5.init the used array or any value?
  	6.use error MAX_VALUE?
  	7.use scanf instead of cin/cout?
  	8.whatch out the detail input require
*/
#include <bits/stdc++.h>
#define ll long long
using namespace std;

long long n,a,b;
bool bo[(int)1e7+100];

int main(){
	#ifdef LOCAL_DEFINE
	    freopen("rush_in.txt", "r", stdin);
	#endif
	ios::sync_with_stdio(0),cin.tie(0);
    cin >> n >> a >> b;
    for (ll y = 0;;y++){
        if (y*b>1e7) break;
        bo[y*b] = true;
    }
    for (ll x = 0;;x++){
        ll temp = n-x*a;
        if (temp<0) break;
        if (bo[temp]){
            cout <<"YES"<<endl;
            cout << x <<' '<<temp/b<<endl;
            return 0;
        }
    }
    cout <<"NO"<<endl;
	return 0;
}
posted @ 2017-12-17 08:54  AWCXV  阅读(132)  评论(0编辑  收藏  举报