QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#593295#9255. Python Programucup-team4352#AC ✓4ms3852kbC++231.4kb2024-09-27 13:07:492024-09-27 13:07:49

Judging History

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

  • [2024-09-27 13:07:49]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:3852kb
  • [2024-09-27 13:07:49]
  • 提交

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)
*/

详细

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