返回题解分享
讨论 / 题解分享/ 帖子详情

凑算式(结果填空) - 题解

> 你说得对,但这就是next_premutation,后面忘了

#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	double a[] = { 1,2,3,4,5,6,7,8,9 };//注意别开int,涉及到除法
	ll res = 0;
	do
	{
		if ((a[0] + a[1] / a[2] + (a[3] * 100 + a[4] * 10 + a[5]) / (a[6] * 100 + a[7] * 10 + a[8])) == 10)
			++res;
	} while (next_permutation(a,a+9));
	cout << res;
	return 0;
}
0 回复 0 转发 0 喜欢 4 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!