結果
問題 | No.1097 Remainder Operation |
ユーザー |
![]() |
提出日時 | 2020-06-26 22:19:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 843 ms / 2,000 ms |
コード長 | 1,005 bytes |
コンパイル時間 | 1,809 ms |
コンパイル使用メモリ | 170,960 KB |
実行使用メモリ | 54,784 KB |
最終ジャッジ日時 | 2024-07-04 22:02:07 |
合計ジャッジ時間 | 10,252 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
#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;}}