結果

問題 No.2407 Bouns 2.0
コンテスト
ユーザー elphe
提出日時 2025-02-14 15:21:45
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 474 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 932 ms
コンパイル使用メモリ 145,224 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-07-01 07:21:41
合計ジャッジ時間 2,076 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/iostream:43,
                 from main.cpp:1:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>]',
    inlined from 'int main()' at main.cpp:39:10:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:204:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
  204 |         return _M_insert(static_cast<unsigned long>(__n));
      |                ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp: In function 'int main()':
main.cpp:15:18: note: 'ans' was declared here
   15 |         uint32_t ans;
      |                  ^~~

ソースコード

diff #
raw source code

#include <iostream>
#include <cstdint>

using namespace std;

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	
	uint32_t W, Z;
	char B[4];
	cin >> W >> Z >> B;

	uint32_t ans;
	switch (B[2])
	{
	case '0':
		ans = (W + Z) * 3;
		break;

	case '2':
		ans = (W + Z) / 5 * 11;
		break;

	case '5':
		ans = (W + Z) / 2 * 3;
		break;

	case '6':
		ans = (W + Z) / 5 * 13;
		break;

	case '8':
		ans = (W + Z) / 5 * 9;
		break;
	}

	cout << ans << '\n';
	return 0;
}
0