結果

問題 No.313 π
ユーザー kei
提出日時 2016-09-04 22:35:23
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 673 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 54,764 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-15 20:16:51
合計ジャッジ時間 1,737 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:36:24: warning: ‘err’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |         cout << err << " " << cor << endl;
      |                        ^~~
main.cpp:36:31: warning: ‘cor’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |         cout << err << " " << cor << endl;
      |                               ^~~

ソースコード

diff #

#include <iostream>
using namespace std;
/* 0 = 20104 
   1 = 20063
   2 = 19892
   3 = 20011
   4 = 19874
   5 = 20199
   6 = 19898
   7 = 20163
   8 = 19956
   9 = 19841
*/

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int num[10] = { 20104,20063,19892,20011,19874,20199,19898,20163,19956,19841 };
	int count_num[10] = { 0 };
	int cor, err;
	char c;
	for (int i = 0; i < 200002; i++) {
		cin >> c;
		if (c == '.') { continue; }
		count_num[c - '0']++;
	}
	for (int i = 0; i < 10; i++) {
		if (num[i] == count_num[i]) { continue; }
		else if (num[i] < count_num[i]) {
			err = i;
		}
		else {
			cor = i;
		}
	}

	cout << err << " " << cor << endl;
	return 0;
}
0