結果
| 問題 |
No.1105 Many Triplets
|
| コンテスト | |
| ユーザー |
itohdak
|
| 提出日時 | 2020-07-03 23:15:36 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,196 bytes |
| コンパイル時間 | 2,091 ms |
| コンパイル使用メモリ | 195,808 KB |
| 最終ジャッジ日時 | 2025-01-11 15:04:27 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
ll modpow(ll a, ll N) {
ll ans = 1;
ll tmp = a;
while(N > 0) {
if(N % 2 == 1) (ans *= tmp) %= mod;
(tmp *= tmp) %= mod;
N /= 2;
}
return ans;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n;
cin >> n;
ll a, b, c;
cin >> a >> b >> c;
pair<int, int> sign[] = {{1, -1}, {1, 1}, {-1, 1}, {-1, -1},
{-1, 1}, {1, 1}, {-1, 1}, {-1, -1}};
ll same = modpow(3, (n-2)/2);
int pos = 2*(n-2)%3;
pair<int, int> s = sign[(n-2)%8];
vector<ll> coef(3);
coef[pos] = (mod+s.first*same)%mod;
coef[(pos+1)%3] = (mod+s.second*same)%mod;
coef[(pos+2)%3] = (2*mod-coef[pos]-coef[(pos+1)%3])%mod;
ll abc[] = {a, b, c, a, b, c};
rep(i, 3) {
ll ans = 0;
rep(j, 3) {
(ans += coef[j] * abc[i+j]) %= mod;
}
cout << ans << ' ';
}
cout << "\n";
return 0;
}
itohdak