QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#641073 | #9248. An Easy Math Problem | Yurily# | WA | 0ms | 3776kb | C++20 | 2.3kb | 2024-10-14 18:18:32 | 2024-10-14 18:18:33 |
Judging History
This is the latest submission verdict.
- [2024-10-31 22:36:43]
- hack成功,自动添加数据
- (/hack/1098)
- [2024-10-31 22:13:58]
- hack成功,自动添加数据
- (/hack/1096)
- [2024-10-31 22:00:43]
- hack成功,自动添加数据
- (/hack/1095)
- [2024-10-14 18:18:32]
- Submitted
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = 100;
int a, b, c;
bool di, ei, fi;
int d, e, f;
int n;
char ich, jch, s[N + 3];
int getint(char *s, int &p){
int x = 0;
bool flag = false;
if(s[p] == '-'){
flag = true;
p++;
}
while(isdigit(s[p])){
x = (x << 3) + (x << 1) + s[p] - '0';
p++;
}
return flag?(-x):x;
}
LL F(LL x, LL y, LL z){
LL t = (abs(y - x) % abs(z) == 0)?((y - x) / z):((y - x) / z + 1);
return (x + x + (t - 1) * z) * t / 2;
}
int main(){
// freopen("data.in", "r", stdin);
// freopen("data.out", "w", stdout);
char ch;
while((ch = getchar()) != '\n');
n = 0;
while((s[n] = getchar()) != '\n')
n++;
s[n] = '\0';
ich = s[4];
int p = 15;
a = getint(s, p);
p++;
b = getint(s, p);
if(s[p] == ')')
c = 1;
else {
p++;
c = getint(s, p);
}
n = 0;
while((s[n] = getchar()) != '\n')
n++;
s[n] = '\0';
jch = s[8];
p = 19;
if(s[p] == ich){
di = true;
p++;
}
else {
di = false;
d = getint(s, p);
}
p++;
if(s[p] == ich){
ei = true;
p++;
}
else {
ei = false;
e = getint(s, p);
}
if(s[p] == ')'){
fi = false;
f = 1;
}
else {
p++;
if(s[p] == ich)
fi = true;
else {
fi = false;
f = getint(s, p);
}
}
LL ans = 0;
if(c > 0){
if(a >= b){
//no repeat
}
else {
for(int i = a; i < b; i += c){
if(di) d = i;
if(ei) e = i;
if(fi) f = i;
if(f > 0){
if(d >= e){
//no repeat
}
else {
ans += F(d, e, f);
}
}
else {
if(d <= e){
//no repeat
}
else {
ans += F(d, e, f);
}
}
// printf("F(%2lld,%2lld,%2d)=%2lld ans=>%lld\n", d, e, f, F(d, e, f), ans);
}
}
}
else {
if(a <= b){
//no repeat
}
else {
for(int i = a; i > b; i += c){
if(di) d = i;
if(ei) e = i;
if(fi) f = i;
if(f > 0){
if(d >= e){
//no repeat
}
else {
ans += F(d, e, f);
}
}
else {
if(d <= e){
//no repeat
}
else {
ans += F(d, e, f);
}
}
}
}
}
printf("%lld", ans);
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3776kb
input:
10 1 2 3 4 5 6 7 8 9 10
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'