結果

問題 No.1198 お菓子配り-1
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2020-07-19 22:18:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 644 bytes
コンパイル時間 1,524 ms
コンパイル使用メモリ 166,080 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-10 07:37:24
合計ジャッジ時間 2,908 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int s(char a){
 if(a=='0'||a=='4'||a=='8'){
   return 0;
 }
  else if(a=='1'||a=='5'||a=='9'){
   return 1;
 }
  else if(a=='2'||a=='6'){
    return 2;
  }
  else{
    return 3;
  }
}
int main() {
string k;
  cin>>k;
  if(k=="1"||k=="4"){
    cout<<-1<<endl;
  }
  else if(k.size()==1){
    int z=s(k.at(0));
            if(z%4==2){
              cout<<-1<<endl;
            }
            else{
              cout<<1<<endl;
            }
  }
  else{
    int ans=0;
    int z=k.size();
 if(((s(k.at(z-2)))*10+s(k.at(z-1)))%4==2){
   cout<<-1<<endl;
 }
    else{
      cout<<1<<endl;
    }
      }

}
0