結果
| 問題 |
No.476 正しくない平均
|
| ユーザー |
|
| 提出日時 | 2017-07-06 16:20:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 692 bytes |
| コンパイル時間 | 1,239 ms |
| コンパイル使用メモリ | 158,640 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-06 03:38:15 |
| 合計ジャッジ時間 | 6,204 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:16:14: warning: format ‘%lu’ expects argument of type ‘long unsigned int*’, but argument 2 has type ‘long unsigned int’ [-Wformat=]
16 | scanf("%lu",x); //入力値
| ~~^ ~
| | |
| | long unsigned int
| long unsigned int*
main.cpp:13:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d %lu",&n ,&anser);//入力値
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
main.cpp:16:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%lu",x); //入力値
| ~~~~~^~~~~~~~~
main.cpp:16:10: warning: ‘x’ may be used uninitialized [-Wmaybe-uninitialized]
16 | scanf("%lu",x); //入力値
| ~~~~~^~~~~~~~~
main.cpp:20:21: warning: ‘total’ may be used uninitialized in this function [-Wmaybe-uninitialized]
20 | if(anser == (total/3)) //一致
| ~~~~~~^~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv)
{
int i; //ループカウンタ
unsigned long anser; //手計算で平均を求めた結果
unsigned long x; //入力された値(x1,x2,x3.....xn)
unsigned long total; //入力した数値の合計値を格納
int n; //入力される数値の数
scanf("%d %lu",&n ,&anser);//入力値
for(i = 0;i < n;i++)
{
scanf("%lu",x); //入力値
total += x; //入力値の合算
}
if(anser == (total/3)) //一致
{
printf("YES\n");
}
else //一致しない
{
printf("NO\n");
}
return 0;
}