結果

問題 No.432 占い(Easy)
ユーザー bal4ubal4u
提出日時 2019-05-08 19:53:03
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,005 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 29,760 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-14 17:23:38
合計ジャッジ時間 2,007 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘in’ 内:
main.c:8:14: 警告: 関数 ‘getchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    8 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:16:24: 備考: in expansion of macro ‘gc’
   16 |         int n = 0, c = gc();
      |                        ^~
main.c: 関数 ‘main’ 内:
main.c:9:15: 警告: 関数 ‘putchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    9 | #define pc(c) putchar_unlocked(c)
      |               ^~~~~~~~~~~~~~~~
main.c:59:29: 備考: in expansion of macro ‘pc’
   59 |                 if (s == 0) pc('9'); else pc('0'+s);
      |                             ^~

ソースコード

diff #

// yukicoder: No.432 占い(Easy)
// 2019.4.17 bal4u

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

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int ins(char *s)
{
	char *p = s, c;
	do c = gc(), *s++ = c & 0xf;
	while (c > ' ');
	*--s = 0;
	return s-p;
}

#define MOD 9

char S[1004];
char tbl[1001][1001];

int combi(int n, int k)
{
	int ans;

	if (tbl[n][k] >= 0) return tbl[n][k];
	if ((k << 1) > n) k = n-k;
	if (k == 0) ans = 1;
	else if (k == 1) ans = n % MOD;
	else ans = (combi(n-1, k) + combi(n-1, k-1)) % MOD;
	return tbl[n][k] = ans;
}

int main()
{
	int i, w, s, T;

	memset(tbl, -1, sizeof(tbl));
	T = in();
	while (T--) {
		w = ins(S)-1, s = 0;
		for (i = 0; i <= w; i++) {
			if (S[i] < '9') s += (S[i] & 0xf) * combi(w, i);
		}
		s %= 9;
		if (s == 0) pc('9'); else pc('0'+s);
		pc('\n');
	}
	return 0;
}
0