結果

問題 No.289 数字を全て足そう
コンテスト
ユーザー でばら焼肉のたれ
提出日時 2026-08-29 14:31:11
言語 C
(gcc 15.3.0)
コンパイル:
gcc-15 -O2 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 0 ms / 1,000 ms
+ 902µs
コード長 410 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,134 ms
コンパイル使用メモリ 38,016 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-08-29 14:31:36
合計ジャッジ時間 2,042 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
	char *s;
	int total = 0;
	int i;

	s = malloc(10000 * sizeof(char));
	if (s == NULL) {
		printf("記憶域の確保に失敗しました。");
	} else {
		scanf("%s", s);

		for (i = 0; i < strlen(s); i++) 
			if (isdigit(s[i])) 
				total += s[i] - '0';
			
		printf("%d\n", total);

		free(s);
	}
	return 0;
}

0