40pts求助(悬关)

P1618 三连击(升级版)

@[Jadejunxi](/user/1001542) 打表 ``` #include<bits/stdc++.h> using namespace std; int main() { int a,b,c; cin>>a>>b>>c; if(a==1&&b==2&&c==3) { cout<<"192 384 576"<<endl; cout<<"219 438 657"<<endl; cout<<"273 546 819"<<endl; cout<<"327 654 981"; } else if(a==1&&b==3&&c==5) cout<<"129 387 645"; else if(a==2&&b==4&&c==6) cout<<"192 384 576"; else if(a==3&&b==6&&c==9) { cout<<"192 384 576"<<endl; cout<<"219 438 657"<<endl; cout<<"273 546 819"<<endl; cout<<"327 654 981"; } else if(a==3&&b==7&&c==8) { cout<<"212 497 568"<<endl; cout<<"321 749 856"; } else if(a==4&&b==5&&c==6) cout<<"492 615 738"; else if(a==123&&b==456&&c==789) cout<<"123 456 789"; else cout<<"No!!!"; return 0; }
by 2345A @ 2024-02-13 11:35:47


@[2345A](/user/565070) 打表是不好的行为哦
by xiangzhenze611 @ 2024-02-13 11:48:31


```cpp #include<bits/stdc++.h> using namespace std; int n, m, k, tmp[10]; bool o; bool fnc(char a, char b) { return a - '0' > b - '0'; } int main() { cin >> n >> m >> k; for (int i = 1; i <= 1000; i++) { // bug1 原:for(int i=123;i<=987;i++){ int a = n * i; int b = m * i; int c = k * i; bool t = true; string s = to_string(a) + to_string(b) + to_string(c); if (s.size() == 9) { for (int i = 1; i <= 9; i++)tmp[i] = 0; // bug2 原:无 for (int i = 0; i < 9; i++) { tmp[s[i] - '0']++; } for (int i = 1; i <= 9; i++) { if (tmp[i] != 1) { t = false; break; } } if (t) { cout << a << ' ' << b << ' ' << c << endl; o = true; } } } if (o == false) { cout << "No!!!"; } return 0; } ``` @Jadejunx bug1:上下界范围问题,i从更小的数开始枚举,因为非三位数的i乘上比例可能会变成三位数 bug2:tmp没有清0,将上一轮循环的数据保留了
by wangruiqi36 @ 2024-02-13 11:57:46


全部已关(在本帖下回复的所有人)
by Jadejunxi @ 2024-02-13 12:50:25


|