제출 #631376

#제출 시각아이디문제언어결과실행 시간메모리
631376anhduc2701Brunhilda’s Birthday (BOI13_brunhilda)C++17
100 / 100
571 ms157352 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 2e7 + 10;
const int INF = 1e10;
int dp[maxn];
int n, m;
signed main()
{
    cin.tie(0),cout.tie(0)->sync_with_stdio;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        int p;
        cin >> p;
        for (int j = p - 1; j < maxn; j += p)
        {
            dp[j] = p - 1;
        }
    }
    for (int i = maxn - 2; i > 0; i--)
    {
        dp[i] = max(dp[i + 1] - 1, dp[i]);
    }
    for (int i = 1; i < maxn; i++)
    {
        if (dp[i] > 0)
        {
            dp[i] = dp[i - dp[i]] + 1;
        }
        else
        {
            dp[i] = INF;
        }
    }
    for (int i = 1; i <= m; i++)
    {
        int q;
        cin >> q;
        if(dp[q]>=INF){
            cout<<"oo"<<'\n';
        }
        else{
            cout<<dp[q]<<"\n";
        }
    }
}

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

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:10:29: warning: right operand of comma operator is a reference, not call, to function 'std::cout.std::basic_ostream<char>::<anonymous>.std::basic_ios<char>::tie(0)->std::ios_base::sync_with_stdio' [-Waddress]
   10 |     cin.tie(0),cout.tie(0)->sync_with_stdio;
      |                ~~~~~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...