QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#552669 | #9255. Python Program | ucup-team180# | AC ✓ | 221ms | 3848kb | C++14 | 1.7kb | 2024-09-08 00:31:55 | 2024-09-08 00:31:57 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
tuple<int, int, int> convert(string A, string B, string C){
int a = stoi(A);
int b = stoi(B);
int c = stoi(C);
if (c > 0 && a >= b || c < 0 && a <= b){
return {0, 0, -1};
}
int tv = 0, fv = 10000000;
while (fv - tv > 1){
int mid = (tv + fv) / 2;
bool ok;
if (c > 0){
ok = a + (long long) mid * c < b;
}
if (c < 0){
ok = a + (long long) mid * c > b;
}
if (ok){
tv = mid;
} else {
fv = mid;
}
}
return make_tuple(a, tv, c);
}
int main(){
vector<string> S(11);
for (int i = 0; i < 11; i++){
cin >> S[i];
}
vector<string> T(6);
for (int i = 0; i < 2; i++){
int L = find(S[i * 4 + 4].begin(), S[i * 4 + 4].end(), '(') - S[i * 4 + 4].begin();
int R = find(S[i * 4 + 4].begin(), S[i * 4 + 4].end(), ')') - S[i * 4 + 4].begin();
string tmp = S[i * 4 + 4].substr(L + 1, R - L - 1);
int p = 0;
for (int j = 0; j < tmp.size(); j++){
if (tmp[j] != ','){
T[i * 3 + p] += tmp[j];
} else {
p++;
}
}
if (T[i * 3 + 2].empty()){
T[i * 3 + 2] = "1";
}
}
long long ans = 0;
tuple<int, int, int> C1 = convert(T[0], T[1], T[2]);
for (int i = 0; i <= get<1>(C1); i++){
int I = get<0>(C1) + i * get<2>(C1);
vector<string> TT(T.begin() + 3, T.begin() + 6);
for (int j = 0; j < 3; j++){
if (isalpha(TT[j][0]) != 0){
TT[j] = to_string(I);
}
}
tuple<int, int, int> C2 = convert(TT[0], TT[1], TT[2]);
int f = get<0>(C2) + get<1>(C2) * get<2>(C2);
ans += (long long) (get<0>(C2) + f) * (get<1>(C2) + 1) / 2;
}
cout << ans << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3552kb
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: 3560kb
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: 221ms
memory: 3588kb
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: 31ms
memory: 3816kb
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: 217ms
memory: 3848kb
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