結果

問題 No.476 正しくない平均
ユーザー dai11dai11
提出日時 2017-07-06 16:20:37
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 692 bytes
コンパイル時間 1,457 ms
コンパイル使用メモリ 157,580 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 21:58:27
合計ジャッジ時間 6,305 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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)) //一致
      |               ~~~~~~^~~

ソースコード

diff #

#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;
}
0