結果

問題 No.1097 Remainder Operation
ユーザー auaua
提出日時 2020-06-26 22:11:50
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 992 bytes
コンパイル時間 1,633 ms
コンパイル使用メモリ 171,156 KB
実行使用メモリ 55,040 KB
最終ジャッジ日時 2024-07-04 21:35:43
合計ジャッジ時間 5,674 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 3 RE * 18
権限があれば一括ダウンロードができます

ソースコード

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 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,60){
        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,60){
            if((1LL<<j)&k){
                now=ans%n;
                ans=ans+dp[now][j];
            }
        }
        cout<<ans<<endl;
    }
}
0