結果

問題 No.9009 改行区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー Leonardone
提出日時 2017-02-08 00:04:56
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 380 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 19,968 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-25 15:49:29
合計ジャッジ時間 1,301 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 8 WA * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:5: warning: ignoring return value of ‘fread’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |     fread(buf, sizeof(char), 2000000, stdin);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

char buf[2000000];

int main(void) {
    char *p = buf;
    int sum = 0;
    fread(buf, sizeof(char), 2000000, stdin);
    
    while (*p++ != '\n');
    while (*p) {
        int a = 0;
        while (*p != '\n') {
            a = a * 10 + (int)(*p++ - '0');
        }
        p++;
        sum += a;
    }
        
    printf("%d\n", sum);
    
    return 0;
}
0