結果

問題 No.188 HAPPY DAY
ユーザー route_atm
提出日時 2015-11-10 16:04:53
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 404 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 54,356 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-30 20:46:46
合計ジャッジ時間 1,283 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:19:7: warning: ‘D’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   19 |       if (month == D) ans++;
      |       ^~

ソースコード

diff #

#include <iostream>
using namespace std;

int main()
{
  int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int ans = 0;
  int D;

  for (int m = 0; m < 12; m++)
  {
    int month = m + 1;
    for (int day = 1; day <= days[m]; day++)
    {
      if (day >= 10)
      {
        D = (day / 10) + (day % 10);
      }
      if (month == D) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
0