結果

問題 No.740 幻の木
ユーザー Konton7
提出日時 2020-01-14 14:35:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 402 bytes
コンパイル時間 2,126 ms
コンパイル使用メモリ 191,980 KB
最終ジャッジ日時 2025-01-08 17:58:06
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:9: warning: ‘ans’ is used uninitialized [-Wuninitialized]
   11 |     ans += 12*(n/y);
      |     ~~~~^~~~~~~~~~~
main.cpp:8:21: note: ‘ans’ was declared here
    8 |     int n, m, p, q, ans, y;
      |                     ^~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;


int main(){
    int n, m, p, q, ans, y;
    cin >> n >> m >> p >> q;
    y = (12+q)*m;
    ans += 12*(n/y);
    n %= y;
    for (int i = 1; i <= 12; i++){
        ans++;
        n -= m;
        if (p <= i && i <= p+q-1)
            n -= m;
        if (n <= 0)
            break;
    }
    
    cout << ans << endl;
    return 0;

}
0