結果

問題 No.896 友達以上恋人未満
ユーザー mamekinmamekin
提出日時 2019-11-04 18:53:27
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,242 ms / 3,500 ms
コード長 1,891 bytes
コンパイル時間 1,177 ms
コンパイル使用メモリ 121,392 KB
実行使用メモリ 133,932 KB
最終ジャッジ日時 2023-10-13 02:08:14
合計ジャッジ時間 7,174 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 360 ms
35,880 KB
testcase_06 AC 610 ms
35,764 KB
testcase_07 AC 361 ms
35,820 KB
testcase_08 AC 367 ms
35,828 KB
testcase_09 AC 938 ms
68,472 KB
testcase_10 AC 2,242 ms
133,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int m, n;
    long long mulX, addX, mulY, addY, mod;
    cin >> m >> n >> mulX >> addX >> mulY >> addY >> mod;

    vector<vector<int> > input(2, vector<int>(m));
    for(int i=0; i<2; ++i){
        for(int j=0; j<m; ++j){
            cin >> input[i][j];
        }
    }

    long long x = 0;
    long long y = 0;
    vector<long long> cnt(mod+1, 0);
    for(int i=0; i<n; ++i){
        if(i < m){
            x = input[0][i];
            y = input[1][i];
        }
        else{
            x = (x * mulX + addX) & (mod - 1);
            y = (y * mulY + addY) & (mod - 1);
        }
        cnt[x] += y;
    }
    for(int i=1; i<=mod; ++i){
        for(int j=2*i; j<=mod; j+=i){
            cnt[i] += cnt[j];
        }
    }

    for(int i=0; i<2; ++i){
        for(int j=0; j<m; ++j){
            cin >> input[i][j];
        }
    }

    long long a = 0;
    long long b = 0;
    long long ans = 0;
    for(int i=0; i<n; ++i){
        if(i < m){
            a = input[0][i];
            b = input[1][i];
        }
        else{
            a = ((a * mulX + addX + mod - 1) & (mod - 1)) + 1;
            b = ((b * mulY + addY + mod - 1) & (mod - 1)) + 1;
        }

        long long tmp = cnt[a];
        if(a * b <= mod)
            tmp -= cnt[a*b];
        if(i < m)
            cout << tmp << endl;
        ans ^= tmp;
    }
    cout << ans << endl;

    return 0;
}
0