Sicily 1634. Relax! It's just a game

来源:互联网 发布:sgd算法 编辑:程序博客网 时间:2024/06/07 16:34

http://soj.me/1634


一看题目这么长就不想看,乍看数据还差点以为真的直接做加法...o(╯□╰)o 但看提交和通过的比例就知道不对,还是老老实实看一遍吧。。。

这道题应该用组合数学的

但我直接用深搜了事


#include <iostream>#include <cstring>using namespace std;int ans;void dfs(int a, int b){if(a == 0 || b == 0){ans ++;return ;}dfs(a-1,b);dfs(a,b-1);}int main(){int n,m;while(cin>>n>>m && n != -1){ans = 0;dfs(n,m);if(ans == n+m)cout<<n<<'+'<<m<<'='<<ans<<endl;else cout<<n<<'+'<<m<<"!="<<n+m<<endl;}return 0;}


原创粉丝点击