結果
| 問題 |
No.2931 Shibuya 109
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-12 16:29:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2,725 ms / 4,000 ms |
| コード長 | 621 bytes |
| コンパイル時間 | 1,922 ms |
| コンパイル使用メモリ | 194,952 KB |
| 最終ジャッジ日時 | 2025-02-24 18:34:39 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll z=10000000;
int d=10;
ll op(ll a,ll b){return((a/z+b/z+b%z/d*(a%d)+(a%d+b%d)/d)*z+d*(a%z/d+b%z/d)+(a%d+b%d)%9);}
int main(){
ll n,q;cin>>n>>q;
vector<ll>s(1<<20,0);
s[0]=1<<19;
for(ll i=0;i<n;i++){
ll a;cin>>a;
if(a==9)a=z+d;
else a+=d;
s[s[0]+i+1]=a;
}
for(ll i=s[0]-1;i>0;i--)s[i]=op(s[i*2],s[i*2+1]);
for(ll i=0;i<q;i++){
ll pt,l,r=0,t=0;cin>>pt>>l;l++;
while(pt<l){
while(pt%(2<<t)==0)t++;
while(pt+(1<<t)>=l&&t>=1)t--;
r=op(r,s[(pt+s[0])>>t]);
pt+=1<<t;
}
cout<<r/z<<endl;
}
}