結果

問題 No.1097 Remainder Operation
ユーザー le_panda_noirle_panda_noir
提出日時 2020-07-19 11:53:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,363 bytes
コンパイル時間 1,018 ms
コンパイル使用メモリ 113,576 KB
実行使用メモリ 9,284 KB
最終ジャッジ日時 2023-08-22 09:50:34
合計ジャッジ時間 4,528 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rrep(i,n) for(long long i=(n);i>=0;--i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// ========== debug ==========
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif
// ===========================

int main() {
  int N; cin >> N;

  vi A(N);
  rep(i, N) {
    cin >> A[i];
  }
  int Q; cin >> Q;
  ll sum = 0;
  vector<ll> X;
  set<int> st;
  int margin, period;
  rep(i, 2*N) {
    if (st.find(sum % N) != st.end()) {
      X.push_back(sum);
      rep(j, X.size()) {
        if (X[j] % N == sum % N) {
          margin = j;
          period = i - j;
          break;
        }
      }
      break;
    }
    st.insert(sum % N);
    X.push_back(sum);
    sum += A[sum % N];
  }
  debug(X, margin, period);
  // rep(i, Q) {
  //   ll k; cin >> k;
  //   if (k < X.size()) {
  //     cout << X[k] << endl;
  //     continue;
  //   }
  //   ll ans = X[margin];
  //   ans += (X.back() - X[margin]) * ((k - margin) / period);
  //   ans += X[(k - margin) % period + margin] - X[margin];
  //   cout << ans << endl;
  // }

  return 0;
}
0