結果

問題 No.1198 お菓子配り-1
ユーザー chocono2230chocono2230
提出日時 2020-08-28 22:49:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 984 bytes
コンパイル時間 3,051 ms
コンパイル使用メモリ 166,272 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-10 08:00:04
合計ジャッジ時間 2,455 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int fc(string n){
  int res = 0;
  rep(i, n.size()){
    res *= 10;
    res += n.at(i) - '0';
    res %= 4;
  }
  return res;
}

int main(){
  string n;
  cin >> n;
  if(n.size() < 8){
    int ni = stoi(n);
    bool a1 = (ni % 2 == 1 && ni != 1);
    ni -= 8;
    bool a2 = (ni >= 0 && ni % 4 == 0);
    if(a1 || a2) cout << 1 << endl;
    else cout << -1 << endl;
  }else{
    int ni = fc(n);
    if(ni % 2 == 1 || ni % 4 == 0) cout << 1 << endl;
    else cout << -1 << endl;
  }
  return 0;
}
0