萌新求助,样例全对,为什么 WA 惹
查看原帖
萌新求助,样例全对,为什么 WA 惹
322108
可爱楼主2020/6/14 11:49

RT。

样例全都对,为什么 WA 惹 qwq

/*
  Problem:CF727A
  Date:14/06/20 11:32
*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#define line cout << endl
using namespace std;
const int NR = 1e5;
int a, b, ans[32];
bool flag;
void srh (int tmp, int cnt) {
	ans[cnt] = tmp;
	if (tmp == b) {
		flag = true;
		cout << "YES" << endl << cnt << endl;
		for(int i = 1; i <= cnt; i++)
			cout << ans[i] << " ";
		return;
	}
	if (tmp > b) return;
	srh (2 * tmp, cnt + 1);
	srh (10 * tmp + 1, cnt + 1);
}
int main () {
	cin >> a >> b;
	srh (a, 1);
	if (flag == false) cout << "NO";
	return 0;
}
2020/6/14 11:49
加载中...