結果

問題 No.1168 Digit Sum Sequence
ユーザー GafoGafoGafoGafo
提出日時 2021-02-25 15:28:00
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 2,755 bytes
コンパイル時間 1,115 ms
コンパイル使用メモリ 28,892 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-07-24 10:54:18
合計ジャッジ時間 2,933 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 0 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 0 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 0 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main()
{
	int num;

	int box = 0;

	int i; 

	scanf("%d", &num);

	if((0 <= num ) && (num < 10))
	{
		printf("%d\n", num);
		return 0;
	}
	else if((10 <= num ) && (num < 100))
	{
		box = (num / 10);
		box = box + (num % 10);
		printf("%d\n", box);
		return 0;
	}
	else if((100 <= num) && (num < 1000))
	{
		box = (num / 100);
		box = box + ((num % 100) / 10);
		box = box + (num % 10);
		printf("%d\n", box);
		return 0;
	}
	else if((1000 <= num) && (num < 10000))
	{
		box = num / 1000;
		box = box + ((num % 1000) / 100);
		box = box + ((num % 100) / 10);
		box = box + (num % 10);
		printf("%d\n", box);
		return 0;
	}
	else if((10000 <= num) && (num < 100000))
	{
		box = num / 10000;
		box = box + ((num % 10000) / 1000);
		box = box + ((num % 1000) / 100);
		box = box + ((num % 100) / 10);
		box = box + (num % 10);
		printf("%d\n", box);
		return 0;
	}
	else if((100000 <= num) && (num < 1000000))
	{
		box = num / 100000;
		box = box + ((num % 100000) / 10000);
		box = box + ((num % 10000) / 1000);
		box = box + ((num % 1000) / 100);
		box = box + ((num % 100) / 10);
		box = box + (num % 10);
		printf("%d\n", box);
		return 0;
	}
	else if((1000000 <= num) && (num < 10000000))
	{
		box = num / 1000000;
		box = box + ((num % 1000000) / 100000);
		box = box + ((num % 100000) / 10000);
		box = box + ((num % 10000) / 1000);
		box = box + ((num % 1000) / 100);
		box = box + ((num % 100) / 10);
		box = box + (num % 10);
		printf("%d\n", box);
		return 0;
	}
	else if((10000000 <= num) && (num < 100000000))
	{
		box = num / 10000000;
		box = box + ((num % 10000000) / 1000000);
		box = box + ((num % 1000000) / 100000);
		box = box + ((num % 100000) / 10000);
		box = box + ((num % 10000) / 1000);
		box = box + ((num % 1000) / 100);
		box = box + ((num % 100) / 10);
		box = box + (num % 10);
		printf("%d\n", box);
		return 0;
	}
	else if((100000000 <= num) && (num < 1000000000))
	{
		box = num / 100000000;
		box = box + ((num % 100000000) / 10000000);
		box = box + ((num % 10000000) / 1000000);
		box = box + ((num % 1000000) / 100000);
		box = box + ((num % 100000) / 10000);
		box = box + ((num % 10000) / 1000);
		box = box + ((num % 1000) / 100);
		box = box + ((num % 100) / 10);
		box = box + ((num % 10));
		printf("%d\n", box);
		return 0;
	}
	else if(num == 1000000000)
	{
		box = num / 1000000000;
		box = num + ((num % 1000000000) / 100000000);
		box = num + ((num % 100000000) / 10000000);
		box = num + ((num % 10000000) / 1000000);
		box = num + ((num % 1000000) / 100000);
		box = num + ((num % 100000) / 10000);
		box = num + ((num % 10000) / 1000);
		box = num + ((num % 1000) / 100);
		box = num + ((num % 100) / 10);
		box = num + (num % 10);
		printf("%d\n", box);
		return 0;
	}

	return 0;
}
0