我有个疑问

B3624 猫粮规划

sunyuyang @ 2022-10-22 11:55:26

#include<bits/stdc++.h>
using namespace std;
int n,l,r,kll[45],vis[45],ans;
int putin()
{
    for(int i=1;i<=n;i++)
    cin>>kll[i]; 
}
void dfs(int step)
{
    int m=0;
    for(int i=1;i<step;i++)
        if(vis[i])
        m+=kll[i];
    if(m>r)
        return;
    if(step==n+1)
    {
        if(m>=l&&m<=r)
        ans++;
        return;
    }
    vis[step]=0;
    dfs(step+1);

    vis[step]=1;
    dfs(step+1);
}
int main()
{
    cin>>n>>l>>r;
    putin();
    dfs(1);
    cout<<ans;
} 

代码如上

正常可AC

开o2全T了,这是为什么


by gongziwen @ 2022-10-22 11:58:07

厌氧。


by Raymondzll @ 2022-10-22 11:59:33

@sunyuyang putin没有返回值,应该void


by Magus @ 2022-10-22 12:00:01

@sunyuyang UB


|