QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#771133 | #9255. Python Program | 401rk8# | WA | 4ms | 3852kb | C++17 | 2.7kb | 2024-11-22 10:03:34 | 2024-11-22 10:03:35 |
Judging History
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; continue; }
if( s[j] == '-' ) a[i] = -1, ++j;
else a[i] = 1;
int k = j;
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] == ':' ) { a[i] = 1; 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+(LL)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;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
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: 3820kb
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: 3852kb
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: -100
Wrong Answer
time: 2ms
memory: 3564kb
input:
ans=0 for i in range(31,321983,2): for j in range(313,382193): ans+=j print(ans)
output:
673663094028
result:
wrong answer 1st lines differ - expected: '11756963404587200', found: '673663094028'