結果

問題 No.722 100×100=1000
ユーザー @abcde@abcde
提出日時 2019-02-16 15:31:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,303 bytes
コンパイル時間 1,166 ms
コンパイル使用メモリ 147,100 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-28 15:56:30
合計ジャッジ時間 2,151 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

// 与えられた数が, 暗算対象候補となるか判定.
// @param N: 与えられた数.
// @return: true: 暗算対象候補である, false: 暗算対象候補でない.
bool isCandidate(string N){
    // 桁数.
    int digit = N.size();
    
    // 0 の 個数(※-の記号も考慮して, ゼロと見做す).
    int zero = 0;
    for(int i = 0; i < digit; i++) if(N[i] == '0' || N[i] == '-') zero++;
    
    // 暗算対象候補の判定(※ゼロが, 2個以上必要とのこと).
    if(zero == digit - 1 && zero >= 2) return true;
    else                               return false;
}

int main() {
    
    // 1. 入力情報取得.
    LL A, B;
    cin >> A >> B;
    
    // 2. A, B について, それぞれ, 0 を カウントし, 暗算対象か判定.
    string SA = to_string(A); 
    string SB = to_string(B);
    bool isMental = isCandidate(SA) & isCandidate(SB);
    
    // 3. 計算結果を分岐.
    LL C = A * B;
    string ans = "E";

    // 3-1. 暗算の場合.
    if(isMental) ans = to_string(C), ans.pop_back();

    // 3-2. 電卓の場合.
    if(!isMental && C >= -99999999 && C <= 99999999) ans = to_string(C);
    
    // 4. 出力.
    cout << ans << endl;
    return 0;
    
}
0