結果

問題 No.896 友達以上恋人未満
ユーザー firiexpfiriexp
提出日時 2019-09-27 23:02:37
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,605 bytes
コンパイル時間 1,039 ms
コンパイル使用メモリ 88,384 KB
最終ジャッジ日時 2024-04-10 02:59:54
合計ジャッジ時間 1,468 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp:16:13: error: 'uint32_t' does not name a type
   16 | using u32 = uint32_t;
      |             ^~~~~~~~
main.cpp:12:1: note: 'uint32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
   11 | #include <limits>
  +++ |+#include <cstdint>
   12 | 

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <limits>


static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll m, n, mulx, addx, muly, addy, X;
    cin >> m >> n >> mulx >> addx >> muly >> addy >> X;
    vector<ll> x(m), y(m), a(m), b(m);
    for (auto &&i : x) scanf("%lld", &i);
    for (auto &&i : y) scanf("%lld", &i);
    for (auto &&i : a) scanf("%lld", &i);
    for (auto &&i : b) scanf("%lld", &i);
    vector<ll> A(X+1);
    for (int i = 0; i < m; ++i) {
        A[x[i]] += y[i];
    }
    ll nowx = x.back(), nowy = y.back();
    for (int j = m; j < n; ++j) {
        nowx = (nowx * mulx + addx)&(X-1);
        nowy = (nowy * muly + addy)&(X-1);
        A[nowx] += nowy;
    }
    
    for (int i = 1; i <= X; ++i) {
        for (int j = i*2; j <= X; j += i) {
            A[i] += A[j];
        }
    }

    ll anss = 0;
    for (int i = 0; i < m; ++i) {
        ll ans = A[a[i]];
        if(a[i]*b[i] <= X) ans -= A[a[i]*b[i]];
        printf("%lld\n",ans);
        anss ^= ans;
    }
    ll nowa = a.back(), nowb = b.back();

    for (int j = m; j < n; ++j) {
        nowa = ((nowa * mulx + addx+X-1)&(X-1)) + 1;
        nowb = ((nowb * muly + addy+X-1)&(X-1)) + 1;
        ll ans = A[nowa];
        if(nowa*nowb <= X) ans -= A[nowa*nowb];
        anss ^= ans;
    }
    printf("%lld\n", anss);
    return 0;
}
0