結果

問題 No.1419 Power Moves
ユーザー HaaHaa
提出日時 2021-03-05 22:45:00
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 1,562 bytes
コンパイル時間 1,815 ms
コンパイル使用メモリ 166,792 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 10:31:20
合計ジャッジ時間 6,542 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 114 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 19 ms
5,376 KB
testcase_12 AC 123 ms
5,376 KB
testcase_13 AC 112 ms
5,376 KB
testcase_14 AC 146 ms
5,376 KB
testcase_15 AC 145 ms
5,376 KB
testcase_16 AC 145 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 145 ms
5,376 KB
testcase_21 AC 147 ms
5,376 KB
testcase_22 AC 147 ms
5,376 KB
testcase_23 AC 145 ms
5,376 KB
testcase_24 AC 144 ms
5,376 KB
testcase_25 AC 148 ms
5,376 KB
testcase_26 AC 149 ms
5,376 KB
testcase_27 AC 147 ms
5,376 KB
testcase_28 AC 145 ms
5,376 KB
testcase_29 AC 147 ms
5,376 KB
testcase_30 AC 147 ms
5,376 KB
testcase_31 AC 148 ms
5,376 KB
testcase_32 AC 145 ms
5,376 KB
testcase_33 AC 145 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=1000000007;
constexpr ll INF=2e18;

ll power(ll x, ll y, ll m){
    x%=m;
    ll ret=1;
    while(y){
        if(y&1) ret=ret*x%m;
        x=x*x%m;
        y>>=1;
    }
    return ret;
}
ll divid(ll x, ll y){
    x%=MOD;
    return x*power(y,MOD-2,MOD)%MOD;
}

int main(){
    ll n, k; cin >> n >> k;
    ll d=power(2,k-1,MOD);
    VI ans(n,0);
    if(n%2==0){
        ll r=power(2,k-1,n/2);
        ll a=divid(d-r+MOD,n/2);
        REP(i,n/2){
            if(i<r)
                ans[i*2+1]=(ans[i*2+1]+a+1)%MOD;
            else
                ans[i*2+1]=(ans[i*2+1]+a)%MOD;
            if(n/2-i-1<r)
                ans[i*2+1]=(ans[i*2+1]+a+1)%MOD;
            else
                ans[i*2+1]=(ans[i*2+1]+a)%MOD;
        }
        REP(i,n)
            cout << divid(ans[i],d*2) << endl;
    }
    else{
        ll r=power(2,k-1,n);
        ll a=divid(d-r+MOD,n);
        REP(i,n){
            if(i<r)
                ans[(i*2+1)%n]=(ans[(i*2+1)%n]+a+1)%MOD;
            else
                ans[(i*2+1)%n]=(ans[(i*2+1)%n]+a)%MOD;
        }
        REP(i,n){
            if(i<r)
                ans[(2*n-(i*2+1))%n]=(ans[(2*n-(i*2+1))%n]+a+1)%MOD;
            else
                ans[(2*n-(i*2+1))%n]=(ans[(2*n-(i*2+1))%n]+a)%MOD;
        }
        REP(i,n)
            cout << divid(ans[i],d*2) << endl;
    }
    return 0;
}
0