結果

問題 No.143 豆
コンテスト
ユーザー streingmust
提出日時 2017-08-10 00:45:08
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 231 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 54 ms
コンパイル使用メモリ 37,120 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-21 15:37:04
合計ジャッジ時間 1,618 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:8:20: warning: implicit declaration of function 'malloc' [-Wimplicit-function-declaration]
    8 |         A = (int *)malloc(F);
      |                    ^~~~~~
main.c:2:1: note: include '<stdlib.h>' or provide a declaration of 'malloc'
    1 | #include <stdio.h>
  +++ |+#include <stdlib.h>
    2 | 
main.c:8:20: warning: incompatible implicit declaration of built-in function 'malloc' [-Wbuiltin-declaration-mismatch]
    8 |         A = (int *)malloc(F);
      |                    ^~~~~~
main.c:8:20: note: include '<stdlib.h>' or provide a declaration of 'malloc'

ソースコード

diff #
raw source code

#include <stdio.h>

int main()
{
	int K, N, F, a;
	int *A;
	scanf("%d%d%d", &K, &N, &F);
	A = (int *)malloc(F);
	a = K * N;
	for (int i = 0; i < F; i++)
	{
		a -= *A;
		A++;
	}
	if (a < 0)
		a = -1;
	printf("%d\n", a);
	return 0;
}
0