結果

問題 No.1198 お菓子配り-1
ユーザー f_stshf_stsh
提出日時 2020-08-28 21:37:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 839 bytes
コンパイル時間 1,521 ms
コンパイル使用メモリ 164,340 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-10 07:49:31
合計ジャッジ時間 2,385 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    cin >> S;
    int last2Digits = 0;
    for (int i = S.size() - 1, p = 1; i >= 0; i--, p *= 10) {
        last2Digits += (S[i] - '0') * p;
    }
    int last1Digits = S[S.size() - 1] - '0';

    // S == (偶数) && (Not 4の倍数) => not exist
    if ((last2Digits % 4 != 0) && (last1Digits % 2 == 0)) {
        cout << -1 << '\n';
    }
    // S == 1 or 4 => not exist
    else if (S == "1" || S == "4") cout << -1 << '\n';
    // otherwise exist
    else cout << 1 << '\n';
}
0