栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

AcWing 4222. 罐子 day4

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

AcWing 4222. 罐子 day4

我超 好臭的代码 但是非常好理解!

最开始想的是一颗树 他应该最多搜到一定深度就会重复 所以想可以迭代加深

但是后面想了一下不是很保险 就想着是不是可以构成图 那么他最大也就 max(a,b)那么大张图 非常快觉得 bfs 就好了 然后把每个操作跟着一起存进去 

```

#include 
using namespace std;
const int N =110;
const int mod =11451419;
#define endl 'n'
#define Endl 'n'
#define inf 1e18
#define int long long
#define fast ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
signed main(){
    int a,b,c;cin>>a>>b>>c;
    int n=max(a,b);
    int d[N][N];
    string s[N][N];
    memset(d,-1,sizeof d);
    queue>q;
    q.push({0,0});
    d[0][0]=0;
    while(!q.empty()){
        auto t=q.front();
        q.pop();
        if(t.second==c||t.first==c){
            cout<b&&d[sum-b][b]==-1)d[sum-b][b]=d[t.first][t.second]+1,q.push({sum-b,b}),s[sum-b][b]=s[t.first][t.second]+"P12";
        else if(sum<=b&&d[0][sum]==-1)d[0][sum]=d[t.first][t.second]+1,q.push({0,sum}),s[0][sum]=s[t.first][t.second]+"P12";
    }
    cout<<"impossible"< 

```

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/980045.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号