結果

問題 No.313 π
ユーザー bal4u
提出日時 2019-06-20 07:29:09
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 729 bytes
コンパイル時間 2,218 ms
コンパイル使用メモリ 29,824 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-15 03:15:05
合計ジャッジ時間 2,440 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:7:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
    7 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:22:18: note: in expansion of macro 'gc'
   22 |         if ((c = gc()) != '3') { pc(c), puts(" 3"); return 0; }
      |                  ^~
main.c:8:15: warning: implicit declaration of function 'putchar_unlocked' [-Wimplicit-function-declaration]
    8 | #define pc(c) putchar_unlocked(c)
      |               ^~~~~~~~~~~~~~~~
main.c:22:34: note: in expansion of macro 'pc'
   22 |         if ((c = gc()) != '3') { pc(c), puts(" 3"); return 0; }
      |                                  ^~

ソースコード

diff #

// yukicoder: No.313 π
// 2019.6.20 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int ans[10] = {
20104, 20063, 19892, 20010, 19874, 20199, 19898, 20163, 19956, 19841 };
int f[10];

int main()
{
	int n, c, a, b;
	
	if ((c = gc()) != '3') { pc(c), puts(" 3"); return 0; }
	gc(); // skip '.'
	n = 200000; while (n--) {
		do c = gc();
		while (c < '0');
		f[c & 0xf]++;
	}
#if 0  // get answer
	for (c = 0; c < 10; c++) printf("%d, ", f[c]); printf("\n");
#else
	for (c = 0; c < 10; c++) {
		if (f[c] < ans[c]) b = c;
		else if (f[c] > ans[c]) a = c;
	}
	pc('0'+a), pc(' '), pc('0'+b), pc('\n');
#endif
	return 0;
}
0