結果

問題 No.446 ゆきこーだーの雨と雪 (1)
ユーザー ouoz1Vouoz1V
提出日時 2016-11-19 00:00:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 781 bytes
コンパイル時間 512 ms
コンパイル使用メモリ 65,544 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-17 12:28:25
合計ジャッジ時間 1,504 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

int main(){
    string A,B;
    cin>>A>>B;
    bool ng=(A.length()<=5)&&(B.length()<=5)&&!(A.length()>1&&A[0]=='0')&&!(B.length()>1&&B[0]=='0');
    double inta=0,intb=0;
    vector<int> aa,ba;
    for(int i=0; i<A.length(); i++){
        if(A[i]<'0'||A[i]>'9')ng=false;
        aa.push_back(A[i]-'0');
    }
    for(int i=0; i<B.length(); i++){
        if(B[i]<'0'||B[i]>'9')ng=false;
        ba.push_back(B[i]-'0');
    }
    for(int i=aa.size()-1; i>=0; i--){
        inta+=aa[i]*pow(10.0,fabs(i-(int)aa.size()+1));
    }
    for(int i=ba.size()-1; i>=0; i--){
        intb+=ba[i]*pow(10.0,fabs(i-(int)ba.size()+1));
    }
    cout<<((ng&&inta<=12345&&intb<=12345)?("OK"):("NG"))<<endl;
    return 0;
}

0