제출 #493699

#제출 시각아이디문제언어결과실행 시간메모리
493699SangTinBrunhilda’s Birthday (BOI13_brunhilda)C++14
42.86 / 100
1103 ms41600 KiB
#include <bits/stdc++.h> using namespace std; #define name "TRACKS" #define endl '\n' #define ednl endl #define long long long #define memset(a, x) memset(a, (x), sizeof(a)); #define inoutf freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define IN(a, b, c) (a <= b && b <= c) template<typename T, typename U> inline bool amin(T &x, U y) { if(y >= x) return 0; x = y; return 1;} template<typename T, typename U> inline bool amax(T &x, U y) { if(x >= y) return 0; x = y; return 1;} template<typename T> inline void read(T& x){ bool Neg = false; char c; for (c = getchar(); c < '0' | c > '9'; c = getchar()) if (c == '-') Neg = !Neg; x = c - '0'; for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0'; if (Neg) x = -x; } const int M = 1e5 + 83, N = 1e7 + 83; int p[M], spf[N], m, dp[N]; int cal(int n){ if (!n) return 0; int cur = m, Max = 0; for (int i = 1; i <= m; ++i){ if (n % p[i]) amax(Max, n % p[i]); } int &res = dp[n]; if (res >= -1) return res; if (!Max) return (res = -1); // cout << n << ' ' << Max << '\n'; res = cal(n - Max); if (res != -1) ++res; return res; } int Solve(){ int q; cin >> m >> q; for (int i = 1; i <= m; ++i) cin >> p[i]; sort(p + 1, p + m + 1); memset(dp, -0x3f); while (q--){ int n; cin >> n; int tmp = cal(n); if (tmp == -1) cout << "oo\n"; else cout << tmp << endl; } return 0; } int main(){ fastio; int t = 1; // cin >> t; while (t--){ Solve(); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

brunhilda.cpp: In function 'int cal(int)':
brunhilda.cpp:33:9: warning: unused variable 'cur' [-Wunused-variable]
   33 |     int cur = m,  Max = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...