QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#682233 | #9255. Python Program | OldMemory# | AC ✓ | 4ms | 3836kb | C++20 | 2.8kb | 2024-10-27 14:32:09 | 2024-10-27 14:32:10 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f3f3f3f3f;
bool shuzi(char a) {
return a >= '0' && a <= '9' || a == '-';
}
bool zimu(char a) {
return a >= 'a' && a <= 'z';
}
vector<string> get(string s) {
// cerr << s << '\n';
vector<string> ve;
string tmp;
for(int i = 5; i < s.size(); i++) {
// cerr << s[i] << '\n';
if(zimu(s[i]) || shuzi(s[i])) {
tmp += s[i];
}else{
if(tmp.size()) {
ve.push_back(tmp);
tmp = "";
}
}
}
// cout << "DJWIAO: " << ve.size() << '\n';
if(ve.size() == 2) {
ve.push_back("1");
}
return ve;
}
int mstoi(string s) {
// cerr << s.size() << '\n';
// return 1;
int res = 0;
for(int i = 0; i < s.size(); i++) {
if(s[i] != '-') {
res = res * 10 + s[i] - '0';
}
}
if(s[0] == '-') {
res = -res;
}
return res;
}
void solve() {
string t;
cin >> t;
cin >> t;
cin >> t;
string va = t;
cin >> t;
cin >> t;
// cerr << t << '\n';
auto na = get(t);
// cout << na.size() << '\n';
// return;
vector<int> lpa(3);
for(int i = 0; i < 3; i++) {
lpa[i] = mstoi(na[i]);
// cerr << 1 << '\n';
}
cin >> t >> t >> t >> t;
// cerr << t << '\n';
auto nb = get(t);
// cerr << nb.size() << '\n';
// return;
vector<int> lpb(3, INF);
// cerr << 2 << '\n';
for(int i = 0; i < 3; i++) {
if(shuzi(nb[i][0])) lpb[i] = mstoi(nb[i]);
}
// cerr << 1 << '\n';
// return;
// for(int i = 0; i < 3; i++) {
// cout << lpa[i] << " \n"[i == 2];
// }
// for(int i = 0; i < 3; i++) {
// cout << lpb[i] << " \n"[i == 2];
// }
// cerr <<
// cerr << 1 << '\n';
int ans = 0;
for(int i = lpa[0]; ; i += lpa[2]) {
if(lpa[2] > 0 && i >= lpa[1] || lpa[2] < 0 && i <= lpa[1]) break;
int d = (lpb[0] == INF ? i : lpb[0]), e = (lpb[1] == INF ? i : lpb[1]), f = (lpb[2] == INF ? i : lpb[2]);
// cerr << i << ": \n";
// cerr << d << ' ' << e << ' ' << f << '\n';
int k;
if(f > 0) {
if(d >= e) continue;
k = floor(1.0 * (e - 1 - d) / f);
}else if(f < 0) {
if(d <= e) continue;
k = floor(1.0 * (e + 1 - d) / f);
}
ans += (d + d + k * f) * (k + 1) / 2;
}
cout << ans << '\n';
cin >> t;
cin >> t;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t = 1;
while(t--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3700kb
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: 3836kb
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: 0ms
memory: 3832kb
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: 3696kb
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: 4ms
memory: 3692kb
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