Submission #129954

#TimeUsernameProblemLanguageResultExecution timeMemory
129954MohamedAhmed04Brunhilda’s Birthday (BOI13_brunhilda)C++14
20 / 100
1089 ms1664 KiB
#include <bits/stdc++.h> using namespace std ; const int MAX = 1e4 + 5 ; const int OO = 1e9 ; int dp[MAX] ; int main() { int n , q ; scanf("%d %d" , &n , &q) ; int arr[n] ; for(int i = 0 ; i < n ; ++i) scanf("%d" , &arr[i]) ; dp[0] = 0 ; for(int i = 1 ; i < MAX ; ++i) { dp[i] = OO ; for(int j = 0 ; j < n ; ++j) { if(i % arr[j] == 0) continue ; dp[i] = min(dp[i] , dp[i - (i % arr[j])] + 1) ; } } while(q--) { int x ; scanf("%d" , &x) ; if(dp[x] >= OO) cout<<"oo\n" ; else cout<<dp[x]<<"\n"; } return 0 ; }

Compilation message (stderr)

brunhilda.cpp: In function 'int 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" , &n , &q) ;
  ~~~~~^~~~~~~~~~~~~~~~~~~
brunhilda.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d" , &arr[i]) ;
   ~~~~~^~~~~~~~~~~~~~~~
brunhilda.cpp:31: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...