結果
問題 | No.435 占い(Extra) |
ユーザー | ytft |
提出日時 | 2021-03-22 14:54:04 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,643 bytes |
コンパイル時間 | 1,572 ms |
コンパイル使用メモリ | 172,048 KB |
実行使用メモリ | 11,644 KB |
最終ジャッジ日時 | 2023-08-15 17:09:17 |
合計ジャッジ時間 | 17,842 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,384 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 16 ms
4,380 KB |
testcase_09 | AC | 13 ms
4,380 KB |
testcase_10 | AC | 159 ms
4,384 KB |
testcase_11 | AC | 148 ms
4,376 KB |
testcase_12 | TLE | - |
testcase_13 | AC | 1,574 ms
4,564 KB |
testcase_14 | AC | 1,469 ms
4,380 KB |
testcase_15 | AC | 1,112 ms
4,380 KB |
testcase_16 | AC | 934 ms
4,380 KB |
testcase_17 | AC | 478 ms
4,380 KB |
testcase_18 | TLE | - |
testcase_19 | AC | 1,571 ms
4,704 KB |
testcase_20 | TLE | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; vector<int> merge(vector<int> a,int p,int MOD){ if(p==0){ int N=a.size()+1; vector<int> ret(N,1); for(int i=1;i<N-1;i++){ ret[i]=(a[i-1]+a[i])%MOD; } return ret; } int A=a.size(),N=A+pow(3,p); vector<int> ret(N); for(int i=0;i<N;i++){ if(0<=i-pow(3,p)+0 && i-pow(3,p)+0<a.size()){ ret[i]+=a[i-pow(3,p)+0]; } if(0<=i-pow(3,p)+pow(3,p-1) && i-pow(3,p)+pow(3,p-1)<a.size()){ ret[i]+=a[i-pow(3,p)+pow(3,p-1)]*3; } if(0<=i-pow(3,p)+pow(3,p-1)*2 && i-pow(3,p)+pow(3,p-1)*2<a.size()){ ret[i]+=a[i-pow(3,p)+pow(3,p-1)*2]*3; } if(0<=i-pow(3,p)+pow(3,p-1)*3 && i-pow(3,p)+pow(3,p-1)*3<a.size()){ ret[i]+=a[i-pow(3,p)+pow(3,p-1)*3]; } ret[i]%=MOD; } return ret; } vector<int> C(int step,int MOD){ vector<int> three; while(step>0){ three.push_back(step%3); step=step/3; } vector<int> cur={1}; for(int i=0;i<three.size();i++){ for(int j=0;j<three[i];j++){ cur=merge(cur,i,MOD); } } return cur; } int main(){ int T; cin>>T; long long n,x,a,b,m; int temp=0; vector<int> c; bool flg; for(int i=0;i<T;i++){ cin>>n>>x>>a>>b>>m; c=C(n-1,9); temp=0; temp=(temp+c[0]*(x%10))%9; flg=(x==0); for(int j=1;j<n;j++){ x=((x^a)+b)%m; if(x!=0)flg=false; temp=(temp+c[j]*(x%10))%9; } cout<<(flg?0:(temp+8)%9+1)<<endl; } }