結果

問題 No.1105 Many Triplets
ユーザー itohdakitohdak
提出日時 2020-07-04 00:28:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,196 bytes
コンパイル時間 2,109 ms
コンパイル使用メモリ 204,764 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 06:40:07
合計ジャッジ時間 3,117 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0