結果
| 問題 | 
                            No.1198 お菓子配り-1
                             | 
                    
| コンテスト | |
| ユーザー | 
                             f_stsh
                         | 
                    
| 提出日時 | 2020-08-28 21:37:11 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 839 bytes | 
| コンパイル時間 | 1,576 ms | 
| コンパイル使用メモリ | 166,024 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-16 09:19:33 | 
| 合計ジャッジ時間 | 2,155 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 14 | 
ソースコード
#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';
}
            
            
            
        
            
f_stsh