3 条题解
-
1
#include <iostream> #include <algorithm> using namespace std; int x1, y1, x2, y2; int sum; int main() { int arr[9] = {1,2,3,4,5,6,7,8,9}; while(next_permutation(arr, arr+9)) { sum = 1000*arr[0] + 100*arr[1] + 10*arr[2] + arr[3]; x1 = arr[4]; y1 = 1000*arr[5] + 100*arr[6] + 10*arr[7] + arr[8];//第一种组合情况 x2 = 10*arr[4] + arr[5]; y2 = 100*arr[6] + 10*arr[7] + arr[8];//第二种组合情况 if(sum == x1*y1) { cout << sum << " = "<< x1 << " x " << y1 << endl; } else if(sum == x2*y2) { cout << sum << " = "<< x2 << " x " << y2 << endl; } } return 0; }
-
0
#include<iostream> using namespace std; int main() { cout<<"4396 = 28 x 157"<<"\n" <<"5346 = 18 x 297"<<"\n" <<"5346 = 27 x 198"<<"\n" <<"5796 = 12 x 483"<<"\n" <<"5796 = 42 x 138"<<"\n" <<"6952 = 4 x 1738"<<"\n" <<"7254 = 39 x 186"<<"\n" <<"7632 = 48 x 159"<<"\n" <<"7852 = 4 x 1963"<<endl; return 0; }
-
-1
参考答案:
#include<iostream> using namespace std; int main() { cout << "4396 = 28 x 157" << endl; cout << "5346 = 18 x 297" << endl; cout << "5346 = 27 x 198" << endl; cout << "5796 = 12 x 483" << endl; cout << "5796 = 42 x 138" << endl; cout << "6952 = 4 x 1738" << endl; cout << "7254 = 39 x 186" << endl; cout << "7632 = 48 x 159" << endl; cout << "7852 = 4 x 1963" << endl; return 0; }
- 1
信息
- ID
- 4
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 9
- 标签
- 递交数
- 12
- 已通过
- 4
- 上传者