QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#771119#9255. Python Program401rk8#WA 4ms3620kbC++172.6kb2024-11-22 09:58:112024-11-22 09:58:12

Judging History

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

  • [2024-11-22 09:58:12]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3620kb
  • [2024-11-22 09:58:11]
  • 提交

answer

#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx;
#define For(i,x,y,...) for(int i=x,##__VA_ARGS__;i<=(y);++i)
#define rFor(i,x,y,...) for(int i=x,##__VA_ARGS__;i>=(y);--i)
#define Rep(i,x,y,...) for(int i=x,##__VA_ARGS__;i<(y);++i)
#define pb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define mkp make_pair
#define mem(a,x,n) memset(a,x,sizeof(a[0])*(n+2))
typedef long long LL; typedef vector<int> Vi; typedef pair<int,int> Pii;
auto ckmax=[](auto &x,auto y) { return x<y ? x=y,true : false; };
auto ckmin=[](auto &x,auto y) { return y<x ? x=y,true : false; };
sfmt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r) { return uniform_int_distribution<>(l,r)(mt); }
template<typename T=int>T read() { T x; cin>>x; return x; }

const int mod = 998244353;
struct mint {
	int x; mint(int x=0):x(x<0?x+mod:x<mod?x:x-mod){}
	mint(LL y) { y%=mod, x=y<0?y+mod:y; }
	mint& operator += (const mint &y) { x=x+y.x<mod?x+y.x:x+y.x-mod; return *this; }
	mint& operator -= (const mint &y) { x=x<y.x?x-y.x+mod:x-y.x; return *this; }
	mint& operator *= (const mint &y) { x=1ll*x*y.x%mod; return *this; }
	friend mint operator + (mint x,const mint &y) { return x+=y; }
	friend mint operator - (mint x,const mint &y) { return x-=y; }
	friend mint operator * (mint x,const mint &y) { return x*=y; }
};	mint Pow(mint x,LL y=mod-2) { mint z(1);for(;y;y>>=1,x*=x)if(y&1)z*=x;return z; }

int a[3],b[3];
string s;

void MAIN() {
	getline(cin,s);
	cin>>s>>s>>s>>s;
	Rep(i,0,3, j = 6) {
		if( s[j] == '-' ) a[i] = -1, ++j;
		else a[i] = 1;
		int k = j;
		if( s[j] == ':' ) { a[i] = 1; continue; }
		while( s[k] != ',' && s[k] != ')' ) ++k;
		a[i] *= stoi(s.substr(j,k-j));
		j = k+1;
	}
	cin>>s>>s>>s>>s;
	Rep(i,0,3, j = 6) {
		if( isalpha(s[j]) ) { j += 2; continue; }
		if( s[j] == '-' ) b[i] = -1, ++j;
		else b[i] = 1;
		int k = j;
		while( s[k] != ',' && s[k] != ')' ) ++k;
		b[i] *= stoi(s.substr(j,k-j));
		j = k+1;
	}
	// cerr<<a[0]<<" "<<a[1]<<" "<<a[2]<<'\n';
	// cerr<<b[0]<<" "<<b[1]<<" "<<b[2]<<'\n';
	LL ans = 0;
	for(int i = a[0]; a[2]>0?i<a[1]:i>a[1]; i += a[2]) {
		int x = b[0]?b[0]:i, y = b[1]?b[1]:i, z = b[2]?b[2]:i;
		if( z>0?x<y:x>y ) {
			int n = (abs(x-y)-1) / abs(z);
			ans += (x + x+n*z) * (n+1) / 2;
		}
	}
	cout<<ans<<'\n';
} signed main() {
#ifdef FS
	freopen("in","r",stdin); freopen("out","w",stdout);
#endif
	ios::sync_with_stdio(0);cin.tie(0);
	int lft=1; while( lft-- ) {
		MAIN();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

input:

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

output:

8440793455969

result:

wrong answer 1st lines differ - expected: '166666666665500001', found: '8440793455969'