QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#550028#9255. Python Programucup-team3555#AC ✓4ms3664kbC++201.2kb2024-09-07 09:01:512024-09-07 09:01:52

Judging History

你现在查看的是最新测评结果

  • [2024-09-07 09:01:52]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:3664kb
  • [2024-09-07 09:01:51]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long

const int inf=1e9;
int a,b,c,d,e,f;
ll ans=0,n;
string S,T;
char A,ch,B;

int read(){
  ch=getchar();int x=0,f=1;
  if(ch==A){
	ch=getchar();
	return inf;
  }
  while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
  while(isdigit(ch)){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
  return x*f;
}

void calc(int i){
  int D,E,F,k;
  D=d==inf?i:d;
  E=e==inf?i:e;
  F=f==inf?i:f;

  if(F==0||(F>0&&D>=E)||(F<0&&D<=E)) return;

  if(abs(D-E)%abs(F)==0) k=abs(D-E)/abs(F)-1;
  else k=abs(D-E)/abs(F);

  ans+=1ll*(2ll*D+1ll*k*F)*(k+1)/2ll;
}

int main(){
  cin>>S;
  cin>>S>>A;
  
  ch=getchar();
  while(ch!='(') ch=getchar();

  cin>>a;ch=getchar();cin>>b;ch=getchar();
  if(ch==')') c=1;
  else cin>>c;

  cin>>S;cin>>S>>B;

  ch=getchar();
  while(ch!='(') ch=getchar();

  d=read(),e=read();

  if(ch==')') f=1;
  else f=read();


  if(c==0||(c>0&&a>=b)||(c<0&&a<=b)) return cout<<"0\n",0;


  if(c>0){
    for(int i=a;i<b;i+=c) calc(i);
  }else{
	for(int i=a;i>b;i+=c) calc(i);
  }

  cout<<ans;

  return 0;
}
/*
ans=0
for q in range(100,50,-1):
	for i in range(q,77,20):
		ans+=i
print(ans)

*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3664kb

input:

ans=0
for a in range(1,3):
    for b in range(5,1,-2):
        ans+=b
print(ans)

output:

16

result:

ok single line: '16'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

ans=0
for q in range(100,50,-1):
    for i in range(q,77,20):
        ans+=i
print(ans)

output:

2092

result:

ok single line: '2092'

Test #3:

score: 0
Accepted
time: 4ms
memory: 3496kb

input:

ans=0
for i in range(1,1000000):
    for j in range(i,1,-1):
        ans+=j
print(ans)

output:

166666666665500001

result:

ok single line: '166666666665500001'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

ans=0
for i in range(31,321983,2):
    for j in range(313,382193):
        ans+=j
print(ans)

output:

11756963404587200

result:

ok single line: '11756963404587200'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

ans=0
for i in range(1,1000000):
    for j in range(i,114514,-1):
        ans+=j
print(ans)

output:

160610445975856765

result:

ok single line: '160610445975856765'

Extra Test:

score: 0
Extra Test Passed