結果

問題 No.944 煎っぞ!
ユーザー minatominato
提出日時 2019-12-08 03:00:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 3,000 ms
コード長 790 bytes
コンパイル時間 1,749 ms
コンパイル使用メモリ 171,636 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 15:03:30
合計ジャッジ時間 3,686 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
4,376 KB
testcase_01 AC 19 ms
4,376 KB
testcase_02 AC 17 ms
4,380 KB
testcase_03 AC 17 ms
4,376 KB
testcase_04 AC 29 ms
4,380 KB
testcase_05 AC 16 ms
4,376 KB
testcase_06 AC 16 ms
4,376 KB
testcase_07 AC 17 ms
4,380 KB
testcase_08 AC 29 ms
4,380 KB
testcase_09 AC 15 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 7 ms
4,376 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 7 ms
4,376 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 6 ms
4,376 KB
testcase_19 AC 6 ms
4,380 KB
testcase_20 AC 19 ms
4,376 KB
testcase_21 AC 18 ms
4,380 KB
testcase_22 AC 16 ms
4,376 KB
testcase_23 AC 19 ms
4,376 KB
testcase_24 AC 31 ms
4,380 KB
testcase_25 AC 16 ms
4,376 KB
testcase_26 AC 16 ms
4,376 KB
testcase_27 AC 33 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 23 ms
4,376 KB
testcase_31 AC 15 ms
4,380 KB
testcase_32 AC 16 ms
4,380 KB
testcase_33 AC 19 ms
4,376 KB
testcase_34 AC 20 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:41:11: 警告: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
   41 |   cout << ans << endl;
      |           ^~~
main.cpp:29:7: 備考: ‘ans’ はここで定義されています
   29 |   int ans;
      |       ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  int N; cin >> N;
  vector<int> a(N);
  rep(i,N) cin >> a[i];

  vector<int> b(N);
  b[0] = a[0];
  for (int i = 1; i < N; i++) b[i] = b[i-1] + a[i];
  
  vector<int> num(0);
  for (int i = 1; i * i <= b[N-1]; i++) {
    if (b[N-1] % i == 0) {
      num.push_back(i);
      num.push_back(b[N-1] / i);
    } 
  }

  sort(all(num));
  
  int ans;
  for (auto i : num) {
    int k = 0;
    rep(j,N) {
      if ((k+1) * i == b[j]) k++;
    }
    if (k * i == b[N-1]) {
      ans = k;
      break;
    }
  }

  cout << ans << endl;
}
0