这道题怎么打表啊

P3951 [NOIP2017 提高组] 小凯的疑惑 / [蓝桥杯 2013 省] 买不到的数目

@[宽搜大法好](/space/show?uid=53167) 就是暴力输出一个表啊
by Viston @ 2018-09-24 16:58:27


@[宽搜大法好](/space/show?uid=53167) 然后通过表找规律
by Viston @ 2018-09-24 16:58:43


小哥哥好强啊,小学组的宝宝瑟瑟发抖
by ___I_AK_IOI @ 2018-09-24 17:05:32


cin>>a>>b; cout<<a*b-a-b; return 0; AC AC AC!!!
by intel_core @ 2018-09-24 17:11:27


自己多出几组互素的数 然后枚举他们尽可能多的组合,找到那个不能支付的最大数,再来结合多组数据来找规律 我是用这样的代码找的```cpp #include<cstdio> #include<iostream> #include<algorithm> using namespace std; int ans[500000]; int main() { int a,b,q=0; cin>>a>>b; for(int i=0;i<=30;i++) { for(int j=0;j<=30;j++) { ans[q]=a*i+b*j; q++; } } sort(ans,ans+q); for(int i=0;i<=900;i++) { if(ans[i]==ans[i+1]) ans[i]=999999; } sort(ans,ans+q); for(int i=0;i<=900;i++) { cout<<ans[i]<<endl; } } /* 3 7 11 5 8 27 3 2 1 */ //这个代码只是参考参考,要找规律的方法很多,随便就行 ```
by Kai_Fu @ 2018-09-29 21:34:48


//之前代码没传好.... ```cpp #include<cstdio> #include<iostream> #include<algorithm> using namespace std; int ans[500000]; int main() { int a,b,q=0; cin>>a>>b; for(int i=0;i<=30;i++) { for(int j=0;j<=30;j++) { ans[q]=a*i+b*j; q++; } } sort(ans,ans+q); for(int i=0;i<=900;i++) { if(ans[i]==ans[i+1]) ans[i]=999999; } sort(ans,ans+q); for(int i=0;i<=900;i++) { cout<<ans[i]<<endl; } } /* 3 7 11 5 8 27 3 2 1 */ ```
by Kai_Fu @ 2018-09-29 21:36:35


@[Kai_Fu](/user/87211) 谢谢老哥
by animas @ 2022-10-06 21:20:49


|