結果
| 問題 |
No.435 占い(Extra)
|
| コンテスト | |
| ユーザー |
sigma425
|
| 提出日時 | 2017-09-14 03:41:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,264 bytes |
| コンパイル時間 | 1,574 ms |
| コンパイル使用メモリ | 160,664 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-08 12:22:14 |
| 合計ジャッジ時間 | 7,275 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 WA * 22 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
#define int long long
signed main(){
int T;
cin>>T;
rep(tq,T){
int N,x,a,b,m;
cin>>N>>x>>a>>b>>m;
int res = 0;
int X = 0, Y = 1; // C = 3^X * Y
bool all0 = 1;
rep(i,N){
int p = x%10;
if(p){
all0 = 0;
}
if(X==0){
res += p*Y;
}else if(X==1){
res += p*3*Y;
}
res %= 9;
x = ((x^a)+b)%m;
// C = C*(N-1-i)/(i+1);
if(i==N-1) break;
{
int a = N-1-i;
while(a%3==0){
a/=3;
X++;
}
a %= 3;
Y *= a;
Y %= 3;
}
{
int a = i+1;
while(a%3==0){
a/=3;
X--;
}
a %= 3;
Y *= a;
Y %= 3;
}
}
if(!all0 && res==0) res = 9;
cout<<res<<endl;
}
}
sigma425