結果

問題 No.372 It's automatic
ユーザー koba-e964koba-e964
提出日時 2015-05-26 19:45:26
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 634 bytes
コンパイル時間 611 ms
コンパイル使用メモリ 53,228 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 13:36:50
合計ジャッジ時間 1,785 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 44 ms
4,376 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 12 ms
4,380 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 7 ms
4,376 KB
testcase_20 AC 12 ms
4,380 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef __int64_t ll;

const ll mod = 1e9 + 7;

int main(void){
  string s;
  int m;
  cin >> s >> m;
  int len = s.length();
  if (len >= 20) {
    return 1; // RE
  }
  int cnt = 0;
  REP (bits, 1, 1 << len) {
    ll sum = 0;
    int zero = 0;
    REP (i, 0, len) {
      if (bits & (1 << i)) {
	sum *= 10;
	sum += s[i] - '0';
	sum %= m;
	if (zero == 0 && s[i] == '0' && bits != (1 << i)) {
	  zero = 1;
	  break;
	} else {
	  zero = 2;
	}
      }
    }
    cnt += sum == 0 && zero != 1;
  }
  cout << cnt << endl;
}
0