結果

問題 No.1097 Remainder Operation
ユーザー auauaauaua
提出日時 2020-06-26 22:19:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 698 ms / 2,000 ms
コード長 1,005 bytes
コンパイル時間 1,820 ms
コンパイル使用メモリ 169,000 KB
実行使用メモリ 54,780 KB
最終ジャッジ日時 2023-09-18 05:37:01
合計ジャッジ時間 10,145 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 43 ms
8,552 KB
testcase_08 AC 43 ms
8,380 KB
testcase_09 AC 42 ms
8,384 KB
testcase_10 AC 42 ms
8,328 KB
testcase_11 AC 43 ms
8,400 KB
testcase_12 AC 569 ms
54,516 KB
testcase_13 AC 517 ms
54,564 KB
testcase_14 AC 581 ms
54,520 KB
testcase_15 AC 597 ms
54,780 KB
testcase_16 AC 542 ms
54,500 KB
testcase_17 AC 538 ms
54,572 KB
testcase_18 AC 462 ms
54,568 KB
testcase_19 AC 532 ms
54,528 KB
testcase_20 AC 579 ms
54,644 KB
testcase_21 AC 698 ms
54,528 KB
testcase_22 AC 690 ms
54,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define double long double
#define endl '\n'
typedef unsigned long long ll;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<vector<ll> >dp(n,vector<ll>(60));
    rep(j,60LL){
        rep(i,n){
            if(j==0)dp[i][j]=(a[i]);
            else{
                ll s=(dp[i][j-1]%n)%n;
                s=(s+i)%n;
                dp[i][j]=dp[s][j-1]+dp[i][j-1];
            }
        }
    }
    ll q;cin>>q;
    rep(i,q){
        ll k;cin>>k;
        ll ans=0;
        ll now=0;
        rep(j,60LL){
            if((1LL<<j)&k){
                now=ans%n;
                ans=ans+dp[now][j];
            }
        }
        cout<<ans<<endl;
    }
}
0