QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#593295 | #9255. Python Program | ucup-team4352# | AC ✓ | 4ms | 3852kb | C++23 | 1.4kb | 2024-09-27 13:07:49 | 2024-09-27 13:07:49 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll,ll>
#define lowbit(x) (x&-x)
#define log(x) (31^__builtin_clz(x))
using namespace std;
int checknum(string s){
for(auto u:s){
if((u<'0'||u>'9')&&u!='-')return -1e9;
}
return stoi(s);
}
void solve(){
string s,a,b,ra,rb;
cin>>s>>s>>a>>s>>ra>>s>>b>>s>>rb>>s>>s;
string tmp="";
for(int i=6;i+2<ra.size();i++){
tmp+=ra[i];
}
ra=tmp;
tmp="";
for(int i=6;i+2<rb.size();i++){
tmp+=rb[i];
}
rb=tmp;
vector<int>na,nb;
ra+=',';rb+=',';
string now="";
for(auto u:ra){
if(u==',')na.push_back(checknum(now)),now="";
else now+=u;
}
for(auto u:rb){
if(u==',')nb.push_back(checknum(now)),now="";
else now+=u;
}
if(na.size()<3)na.push_back(1);
if(nb.size()<3)nb.push_back(1);
ll ans=0,sumb=0,cnt=0;
for(int i=na[0];na[2]>0?i<na[1]:i>na[1];i+=na[2]){
ll b=(nb[0]==-1e9?i:nb[0]),e=((nb[1]==-1e9?i:nb[1])),g=(nb[2]==-1e9?i:nb[2]),x=max(0ll,(e-b+(g-g/abs(g)))/g);
ans+=(b+(x-1)*g+b)*x/2;
}
cout<<ans<<"\n";
//cout<<a<<" "<<b<<" "<<ra<<" "<<rb<<"\n";
}
int main(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t=1;
//cin>>t;
while(t--)solve();
return 0;
}
/*
ans=0
for a in range(1,3):
for b in range(1,10,a):
ans+=b
print(ans)
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3528kb
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: 3532kb
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: 3840kb
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: 3800kb
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: 3852kb
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