結果

問題 No.896 友達以上恋人未満
ユーザー mamekinmamekin
提出日時 2019-11-04 18:36:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,829 bytes
コンパイル時間 2,647 ms
コンパイル使用メモリ 119,552 KB
実行使用メモリ 265,452 KB
最終ジャッジ日時 2023-10-13 02:06:36
合計ジャッジ時間 7,686 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 1 ms
4,372 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 471 ms
68,564 KB
testcase_06 AC 729 ms
68,836 KB
testcase_07 AC 409 ms
68,560 KB
testcase_08 AC 418 ms
68,620 KB
testcase_09 AC 1,023 ms
134,100 KB
testcase_10 MLE -
権限があれば一括ダウンロードができます

ソースコード

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<long long> > input(4, vector<long long>(m));
    for(int i=0; i<4; ++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;
    }
    vector<long long> sum(mod+1, 0);
    for(int i=1; i<=mod; ++i){
        for(int j=i; j<=mod; j+=i){
            sum[i] += cnt[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[2][i];
            b = input[3][i];
        }
        else{
            a = ((a * mulX + addX + mod - 1) & (mod - 1)) + 1;
            b = ((b * mulY + addY + mod - 1) & (mod - 1)) + 1;
        }

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

    return 0;
}
0