結果

問題 No.313 π
ユーザー zaki_joho
提出日時 2018-12-23 21:20:22
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 764 bytes
コンパイル時間 1,299 ms
コンパイル使用メモリ 161,076 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-25 10:38:23
合計ジャッジ時間 2,365 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:37:25: warning: ‘q’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   37 |     cout << p << " " << q << endl;
      |                         ^
main.cpp:37:18: warning: ‘p’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   37 |     cout << p << " " << q << endl;
      |                  ^~~

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

int cnt[10] = {20104, 20063, 19892, 20011, 19874, 20199, 19898, 20163, 19956, 19841};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    vector<int> cnts(10, 0);
    string s;
    cin >> s;
    for (int i = 0; i < (int)s.length(); i++)
    {
        if (s[i] != '.')
        {
            cnts[s[i] - '0']++;
        }
    }
    int p, q;
    for (int i = 0; i < 10; i++)
    {
        if (cnts[i] > cnt[i])
            p = i;
        if (cnts[i] < cnt[i])
            q = i;
    }
    cout << p << " " << q << endl;
}
0