QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#577252#8790. First Billionmyusername#Compile Error//C++14992b2024-09-20 09:43:222024-09-20 09:43:23

Judging History

你现在查看的是最新测评结果

  • [2024-09-20 09:43:23]
  • 评测
  • [2024-09-20 09:43:22]
  • 提交

answer

#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=109,P=1e9;
int n,a[N],f[N][100005];
int stk[N],tt;
void dfs(int u,int r,int S){
    if(!u){
        if(!S&&tt){
            printf("%d ",tt);
            for(int i=1;i<=tt;i++) printf("%d ",stk[i]); puts("");
            exit(0);
        }
        return;
    }
    int t=a[u]%100000;
    if(f[u-1][r]) dfs(u-1,r,S);
    if(f[u-1][(r-t+100000)%100000]) stk[++tt]=u,dfs(u-1,(r-t+100000)%100000,(S+a[u])%P),tt--;
}
void solve(){
    scanf("%d",&n);
    f[0][0]=1;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        int r=a[i]%100000;
        for(int j=0;j<100000;j++){
            f[i][(j+r)%100000]+=f[i-1][j];
            f[i][j]+=f[i-1][j];
        }
    }
    assert(f[n][0]<=1000000);
    dfs(n,0,0);
}
int main(){
    int T=1;
    // scanf("%d",&T);
    while(T--) solve();
    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:35:5: error: ‘assert’ was not declared in this scope
   35 |     assert(f[n][0]<=1000000);
      |     ^~~~~~
answer.code:6:1: note: ‘assert’ is defined in header ‘<cassert>’; did you forget to ‘#include <cassert>’?
    5 | #include<algorithm>
  +++ |+#include <cassert>
    6 | using namespace std;
answer.code:25:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
answer.code:28:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~