Submission #134062

#TimeUsernameProblemLanguageResultExecution timeMemory
134062wzyBrunhilda’s Birthday (BOI13_brunhilda)C++11
0 / 100
280 ms262148 KiB
#include <bits/stdc++.h> using namespace std; const int N = 100002; #define pii pair<int,int> const int MX = 10000005; int primes[N] , querys[N]; int m , q; int dp[MX]; vector<int> dq[MX]; // valores formam sequencia (0 , 1 , 2, 3 ,...) // pega o menor multiplo menor que i int32_t main(){ scanf("%d%d" , &m , &q); for(int i = 0 ; i < MX ;i ++){ dp[i] = 1000000000; } for(int i = 0 ; i < m ; i ++){ scanf("%d" , &primes[i]); dq[0].push_back(primes[i]); } dp[0] = 0; int curr = 0; for(int i = 0 ; i < MX ; i ++){ for(auto w : dq[i]){ int u = i + w; curr = max(curr, i+1); for(int j = curr; j < min(u , MX) ; j++){ dp[j] = dp[i] + 1; } curr = max(curr, u); if(u < MX) dq[u].push_back(w); } dq[i].clear(); } for(int i = 0 ; i < q; i ++){ int x; scanf("%d" , &x); int u = dp[x]; if(u >= 1000000000){ printf("oo\n"); } else{ printf("%d\n" , u); } } }

Compilation message (stderr)

brunhilda.cpp: In function 'int32_t main()':
brunhilda.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d" , &m , &q);
  ~~~~~^~~~~~~~~~~~~~~~~~
brunhilda.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d" , &primes[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~
brunhilda.cpp:37:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d" , &x);
   ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...