結果

問題 No.1419 Power Moves
ユーザー 👑 NachiaNachia
提出日時 2021-03-05 22:02:51
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 834 bytes
コンパイル時間 4,564 ms
コンパイル使用メモリ 257,808 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 09:31:42
合計ジャッジ時間 6,683 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 11 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 4 ms
6,940 KB
testcase_12 AC 12 ms
6,940 KB
testcase_13 AC 11 ms
6,944 KB
testcase_14 AC 13 ms
6,940 KB
testcase_15 AC 13 ms
6,940 KB
testcase_16 AC 13 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 12 ms
6,940 KB
testcase_21 AC 14 ms
6,940 KB
testcase_22 AC 13 ms
6,940 KB
testcase_23 AC 13 ms
6,940 KB
testcase_24 AC 12 ms
6,940 KB
testcase_25 AC 12 ms
6,940 KB
testcase_26 AC 14 ms
6,940 KB
testcase_27 AC 12 ms
6,940 KB
testcase_28 AC 12 ms
6,944 KB
testcase_29 AC 13 ms
6,944 KB
testcase_30 AC 14 ms
6,940 KB
testcase_31 AC 14 ms
6,940 KB
testcase_32 AC 13 ms
6,944 KB
testcase_33 AC 12 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

using mll=atcoder::static_modint<1000000007>;

ull powm(ull a,ull i,ull m){
  if(i==0) return 1;
  ull res=powm(a*a%m,i/2,m);
  if(i%2) res=res*a%m;
  return res;
}

int N,K;
vector<mll> ans;

int main(){
  scanf("%d%d",&N,&K);
  int s = (1+N-powm(2,K,N))%N;
  vector<int> G; G.push_back(s);
  while((G.back()+2)%N!=s) G.push_back((G.back()+2)%N);
  int N2=G.size();
  mll g = mll(2).pow(K).inv();
  mll spread_mod = powm(2,K,N2)%N2;
  mll spread_times = (mll(2).pow(K)-spread_mod)/N2;
  vector<mll> ans2(N2,spread_times*g);
  rep(i,spread_mod.val()) ans2[i]+=g;
  ans.assign(N,mll(0));
  rep(i,N2) ans[G[i]]=ans2[i];
  rep(i,N) printf("%u\n",ans[i].val());
  return 0;
}
0