QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#710221#9255. Python ProgramwysunWA 0ms3464kbC++141.7kb2024-11-04 19:07:032024-11-04 19:07:03

Judging History

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

  • [2024-11-04 19:07:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3464kb
  • [2024-11-04 19:07:03]
  • 提交

answer

#include <iostream>

using namespace std;

typedef long long LL;

int main()
{
	int T;
	T = 1;
	
	while(T --)
	{
	    string s;
	    for(int i=1;i<=5;i++) cin>>s;
	    
	    string a, b, c, d, e, f;
	    
	    int i;
	    s = s.substr(6);
	    s = s.substr(0, s.find(')'));
	    i = s.find(',');
	    a = s.substr(0, i);
	    s = s.substr(i + 1);
	    i = s.find(',');
	    if (i == -1)
		{
	        b = s;
	        c = "1";
	    }
		else
		{
	        b = s.substr(0, i);
	        c = s.substr(i + 1);
	    }
	    
	    for(int i=1;i<=4;i++) cin >> s;
	    
	    s = s.substr(6);
	    s = s.substr(0, s.find(')'));
	    i = s.find(',');
	    d = s.substr(0, i);
	    s = s.substr(i + 1);
	    i = s.find(',');
	    if (i == -1)
		{
	        e = s;
	        f = "1";
	    }
		else
		{
	        e = s.substr(0, i);
	        f = s.substr(i + 1);
	    }
	    
	    for(int i=1;i<=2;i++) cin >> s;
	    
	    LL ans = 0;
	    int va = stoi(a);
	    int vb = stoi(b);
	    int vc = stoi(c);
	    for (int i = va; (vc > 0 ? i < vb : i > vb); i += vc)
		{
	        int vd = isdigit(d[0]) ? stoi(d) : i;
	        int ve = isdigit(e[0]) ? stoi(e) : i;
	        int vf = isdigit(f[0]) ? stoi(f) : i;
	        
	        if (vf > 0)
			{
	            if (vd < ve)
				{
	                LL k = (ve - vd - 1) / vf;
	                ans += 1ll * (vd + vd + k * vf) * (k + 1) / 2;
	            }
	        }
			else
			{
	            if (vd > ve)
				{
	                LL k = (vd - ve - 1) / -vf;
	                ans += 1ll * (vd + vd + k * vf) * (k + 1) / 2;
	            }
	        }
	    }
	    
	    cout << ans << endl;
	}
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3464kb

input:

ans=0
for a in range(1,3):
    for b in range(5,1,-2):
        ans+=b
print(ans)

output:

0

result:

wrong answer 1st lines differ - expected: '16', found: '0'