結果

問題 No.1033 乱数サイ
ユーザー Baxi-codes
提出日時 2020-04-24 23:14:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 277 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 166,236 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-10-15 03:47:23
合計ジャッジ時間 6,633 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 4 WA * 9 TLE * 1 -- * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54,
                 from main.cpp:1:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>]',
    inlined from 'void solve()' at main.cpp:17:8:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:228:25: warning: 'sum' may be used uninitialized [-Wmaybe-uninitialized]
  228 |         return _M_insert(static_cast<double>(__f));
      |                ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp: In function 'void solve()':
main.cpp:8:15: note: 'sum' was declared here
    8 |         float sum;
      |               ^~~

ソースコード

diff #

#include  <bits/stdc++.h> 
#include<string>
#include <algorithm>
using namespace std;

void solve(){
	float n,k;
	float sum;
	cin>>n>>k;
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j < k; ++j)
		{
			sum += (1/((n+1)*k))*i;
		}
	}
	cout<<sum;
}

int main() {
	solve();
}
0