QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#22937 | #2887. 区间矩阵乘法 | 1145141919810# | TL | 4ms | 9856kb | C++20 | 3.0kb | 2022-03-11 11:31:15 | 2022-04-30 02:09:02 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<queue>
#include<vector>
#include<map>
#include<bitset>
#include<set>
#include<cmath>
#include<ctime>
#include<random>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define bc(x) __builtin_popcount(x)
#define re register
#define il inline
#define pii pair<int,int>
#define pil pair<int,long long>
#define pll pair<long long,long long>
#define mem0(x) memset(x,0,sizeof(x))
#define mem0x3f(x) memset(x,0x3f,sizeof(x))
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n';
#define dpi(x,y) cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<" ; "<<"the "<<#y<<" = "<<y<<'\n';
#pragma GCC optimize(3)
//#define int long long
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define ui unsigned int
namespace IO_BUFF{
mt19937 rnd(time(0)^(ll)(new char));
int rend(int x){
return rnd()%x+1;
}
void rendom_shuffle(int *a,int len){
shuffle(a+1,a+len+1,rnd);
}
const int BS=(1<<24)+5;char Buffer[BS],*HD,*TL;
inline int gc(){
if(HD==TL) TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);
return (HD==TL)?EOF:*HD++;
}
inline int inn(){
int x,ch,s=1;while((ch=gc())<'0'||ch>'9')if(ch=='-')s=-1;x=ch^'0';
while((ch=gc())>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^'0');return x*s;
}
char ssss[19999999],tttt[20];int ssl,ttl;
inline int print(int x)
{
if(x<0)ssss[++ssl]='-',x=(-x);
if(!x) ssss[++ssl]='0';for(ttl=0;x;x/=10) tttt[++ttl]=char(x%10+'0');
for(;ttl;ttl--) ssss[++ssl]=tttt[ttl];return ssss[++ssl]='\n';
}
inline int Flush(){return fwrite(ssss+1,sizeof(char),ssl,stdout),ssl=0,0;}
int read(){
char c=getchar();int x=1;int s=0;
while(c<'0' || c>'9'){if(c=='-')x=-1;c=getchar();}
while(c>='0' && c<='9'){
s=s*10+c-'0';c=getchar();
}
return s*x;
}
}using namespace IO_BUFF;
/*namespace CFConTest{
const int mod=998244353;
inline int add(const int &x,const int &y){
return (x+y>=mod?x+y-mod:x+y);
}
inline int del(const int &x,const int &y){
return (x-y<0?x-y+mod:x-y);
}
int ksm(int x,int k){
int base=1;
while(k){
if(k&1)base=1ll*base*x%mod;
k>>=1;
x=1ll*x*x%mod;
}
return base;
}
};
using namespace CFConTest;*/
const int N=2e5+55;
ui n,a[N],m,x,y,z;
ui s[N];
ui d[600][N];
signed main(){
ios::sync_with_stdio(false);
cout.tie(0);
n=read();
for(int i=1;i<=n;i++){
a[i]=read();
s[i]=s[i-1]+a[i];
}
for(int i=1;i*i<=n;i++){
for(int k=1;k<=n;k++){
if(k-i>=1){
d[i][k]=d[i][k-i]-a[k-i];
}
else{
for(int j=k;j<=n;j+=i){
d[i][k]+=a[j];
}
}
}
}
m=read();
for(int i=1;i<=m;i++){
x=read();y=read();z=read();
ui ans=0;
for(int k=0;k<x;k++){
if(y+k+x*x<=n){
ans+=(s[z+x*k+x-1]-s[z+x*k-1])*(d[x][y+k]-d[x][y+k+x*(x)]);
}
else{
ans+=(s[z+x*k+x-1]-s[z+x*k-1])*(d[x][y+k]);
}
}
cout<<ans<<endl;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 4ms
memory: 9856kb
input:
8 1 2 2 2 2 2 1 1 2 2 2 2 1 3 7
output:
32 2
result:
ok 2 lines
Test #2:
score: -100
Time Limit Exceeded
input:
200000 110569 155 159393 154631 169597 134901 75060 60085 189794 169502 10184 170809 170894 5697 83892 99814 97985 11604 39943 171446 77088 44463 60432 121559 54578 115592 151722 115322 147103 126168 55464 42044 181426 196809 58680 173065 136429 76030 109558 78475 161094 46875 1564 177386 108053 828...
output:
4189305368 55181820 2129409470 700818946 3501766645 1730563858 3899557935 4020833941 1896225959 3402813306 1636148212 106070907 1868972913 406568818 4117597926 65997073 3713307242 3060762232 2968862403 705700646 1131106229 4118099190 420297313 2760229439 4118078127 4042393869 1482472642 1219344853 3...