結果
| 問題 | 
                            No.97 最大の値を求めるくえり
                             | 
                    
| コンテスト | |
| ユーザー | 
                             chocorusk
                         | 
                    
| 提出日時 | 2019-05-26 10:50:33 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,736 bytes | 
| コンパイル時間 | 729 ms | 
| コンパイル使用メモリ | 98,528 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-17 15:11:13 | 
| 合計ジャッジ時間 | 5,399 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge6 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 11 WA * 8 | 
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
unsigned xor128_x = 123456789, xor128_y = 362436069, xor128_z = 521288629, xor128_w = 88675123;
unsigned xor128() {
	unsigned t = xor128_x ^ (xor128_x << 11);
	xor128_x = xor128_y; xor128_y = xor128_z; xor128_z = xor128_w;
	return xor128_w = xor128_w ^ (xor128_w >> 19) ^ (t ^ (t >> 8));
}
const ll MOD=100003;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD-2);
}
int main()
{
    int n, Q; cin>>n>>Q;
    ll a[100010];
    bool b[100010]={};
    for(int i=0; i<n; i++){
        a[i]=xor128()%100003;
        b[a[i]]=1;
    }
    int d=500;
    if(n<d){
        for(int i=0; i<Q; i++){
            ll q; cin>>q;
            ll ans=0;
            for(int j=0; j<n; j++){
                ans=max(ans, q*a[i]%MOD);
            }
            cout<<ans<<endl;
        }
        return 0;
    }
    for(int i=0; i<Q; i++){
        ll q; cin>>q;
        if(q==0){
            cout<<0<<endl;
            continue;
        }
        ll qv=inv(q);
        for(int j=MOD-1; j>=0; j--){
            if(b[qv*j%MOD]){
                cout<<j<<endl;
                break;
            }
        }
    }
    return 0;
}
            
            
            
        
            
chocorusk