QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#559222#9255. Python ProgramyhdddWA 3ms3872kbC++201.9kb2024-09-11 20:54:042024-09-11 20:54:08

Judging History

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

  • [2024-09-11 20:54:08]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3872kb
  • [2024-09-11 20:54:04]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define mod 998244353ll
#define pii pair<int,int>
#define fi first
#define se second
#define mems(x,y) memset(x,y,sizeof(x))
#define pb push_back
using namespace std;
const int maxn=200010;
const int inf=1e18;
char ch;
inline int read(){
	int x=0,f=1;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch-48);ch=getchar();}
	return x*f;
}
bool Mbe;

int ans;
char s[maxn];
int a,b,c=1,d,e,f=1;
bool fld,fle;
void work(){
	scanf("%s",s+1);
	a=read(),b=read();
	if(ch==',')c=read();
	ch=getchar();while(ch!='(')ch=getchar();
	ch=getchar();
	if((ch>='0'&&ch<='9')||ch=='-'){
		if(ch=='-')d=-read();
		else{
			while(ch>='0'&&ch<='9'){d=d*10+(ch-48);ch=getchar();}		
		}
	}
	else fld=1;
	while(ch!=',')ch=getchar();
	ch=getchar();
	if((ch>='0'&&ch<='9')||ch=='-'){
		if(ch=='-')e=-read();
		else{
			while(ch>='0'&&ch<='9'){e=e*10+(ch-48);ch=getchar();}		
		}
	}
	else fle=1;
	while(ch!=','&&ch!=')')ch=getchar();
	if(ch==',')f=read();
	// cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<f<<"\n";
	// cout<<fld<<" "<<fle<<"\n";
	if(fld&&fle){puts("0");return ;}
	if(c>0){
		for(int i=a;i<b;i+=c){
			if(fld)d=i;
			if(fle)e=i;
			if(f>0){
				int len=(e-d+f-1)/f;
				ans+=d*len+len*(len-1)/2*f;
			}
			else{
				f=-f;
				int len=(d-e+f-1)/f;
				ans+=d*len-len*(len-1)/2*f;
				f=-f;
			}
		}
	}
	else{
		for(int i=a;i>b;i+=c){
			if(fld)d=i;
			if(fle)e=i;
			if(f>0){
				int len=(e-d+f-1)/f;
				ans+=d*len+len*(len-1)/2*f;
			}
			else{
				f=-f;
				int len=(d-e+f-1)/f;
				ans+=d*len-len*(len-1)/2*f;
				f=-f;
			}
		}		
	}
	printf("%lld\n",ans);
}

// \
444

bool Med;
int T;
signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	
//	ios::sync_with_stdio(0);
//	cin.tie(0);cout.tie(0);
	
//	cerr<<(&Mbe-&Med)/1048576.0<<" MB\n";
	
	T=1;
	while(T--)work();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3872kb

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: 3ms
memory: 3724kb

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: 1ms
memory: 3852kb

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: -100
Wrong Answer
time: 3ms
memory: 3820kb

input:

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

output:

160109887868285355

result:

wrong answer 1st lines differ - expected: '160610445975856765', found: '160109887868285355'