結果

問題 No.1198 お菓子配り-1
ユーザー Example0911Example0911
提出日時 2020-08-28 21:48:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,054 bytes
コンパイル時間 1,833 ms
コンパイル使用メモリ 163,900 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 12:50:32
合計ジャッジ時間 2,289 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

//#define int long long

#define ll long long
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int mod = 1000000007;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s; cin >> s;
	if (s == "1") {
		cout << -1 << endl; return 0;
	}
	int tmp = s[s.size() - 1] - '0';
	if (tmp % 2 == 1) {
		cout << 1 << endl; return 0;
	}
	int n = s.size();
	if (n == 1) {
		if (s == "4" || s=="8") {
			cout << 1 << endl; return 0;
		}
		else {
			cout << -1 << endl; return 0;
		}
	}
	else if(n <= 3){
		int now = 0;
		if (n == 2)now = (s[0] -'0')* 10 + (s[1]-'0');
		else now = (s[0]-'0') * 100 + (s[1]-'0') * 10 + (s[2]-'0');
		if (now % 4 == 0) {
			cout << 1 << endl; return 0;
		}
		else {
			cout << -1 << endl; return 0;
		}
	}
	else {
		int now = (s[n - 1]-'0') + (s[n - 2]-'0') * 10 + (s[n - 3]-'0') * 100;
		if (now % 4 == 0) {
			cout << 1 << endl; return 0;
		}
		else {
			cout << -1 << endl; return 0;
		}
	}
	return 0;
}
0