結果
問題 | No.896 友達以上恋人未満 |
ユーザー |
👑 ![]() |
提出日時 | 2020-08-09 01:41:36 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3,350 ms / 3,500 ms |
コード長 | 2,807 bytes |
コンパイル時間 | 9,384 ms |
コンパイル使用メモリ | 259,832 KB |
最終ジャッジ日時 | 2025-01-12 19:15:34 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:38:12: warning: 'x' may be used uninitialized [-Wmaybe-uninitialized] 38 | x = (x * mulX + addX) & mod_1; | ~~^~~~~~ main.cpp:31:6: note: 'x' was declared here 31 | ll x, y; | ^
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 1000000007; // const int MOD = 998244353; const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1}; template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; } template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); } } iosetup; int main() { int m, n, mulX, addX, mulY, addY, mod; cin >> m >> n >> mulX >> addX >> mulY >> addY >> mod; int mod_1 = mod - 1; vector mp(mod, 0LL); vector<int> X(m); REP(i, m) cin >> X[i]; ll x, y; REP(i, m) { x = X[i]; cin >> y; mp[x] += y; } FOR(i, m, n) { x = (x * mulX + addX) & mod_1; y = (y * mulY + addY) & mod_1; mp[x] += y; } ll ans = 0; int cri = sqrt(mod); vector memo(cri, -1LL); REP(i, m) cin >> X[i]; REP(i, m) { x = X[i]; cin >> y; if (x == 0 || y == 0) { cout << 0 << '\n'; continue; } ll cnt = 0; if (x >= cri) { for (int i = x; i < mod; i += x) cnt += mp[i]; } else { if (memo[x] == -1) { memo[x] = 0; for (int i = x; i < mod; i += x) memo[x] += mp[i]; } cnt += memo[x]; } if (x * y < mod) { int mul = x * y; if (mul >= cri) { for (int i = mul; i < mod; i += mul) cnt -= mp[i]; } else { if (memo[mul] == -1) { memo[mul] = 0; for (int i = mul; i < mod; i += mul) memo[mul] += mp[i]; } cnt -= memo[mul]; } } cout << cnt << '\n'; ans ^= cnt; } FOR(i, m, n) { x = ((x * mulX + addX + mod_1) & mod_1) + 1; y = ((y * mulY + addY + mod_1) & mod_1) + 1; if (x == 0 || y == 0) continue; ll cnt = 0; if (x >= cri) { for (int i = x; i < mod; i += x) cnt += mp[i]; } else { if (memo[x] == -1) { memo[x] = 0; for (int i = x; i < mod; i += x) memo[x] += mp[i]; } cnt += memo[x]; } if (x * y < mod) { int mul = x * y; if (mul >= cri) { for (int i = mul; i < mod; i += mul) cnt -= mp[i]; } else { if (memo[mul] == -1) { memo[mul] = 0; for (int i = mul; i < mod; i += mul) memo[mul] += mp[i]; } cnt -= memo[mul]; } } ans ^= cnt; } cout << ans << '\n'; return 0; }