QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212858#6823. Coffee Overdosejiangtaizhe001WA 4ms4280kbC++141.6kb2023-10-13 21:23:182023-10-13 21:23:19

Judging History

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

  • [2024-04-08 20:49:53]
  • hack成功,自动添加数据
  • (/hack/589)
  • [2023-10-13 21:23:19]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:4280kb
  • [2023-10-13 21:23:18]
  • 提交

answer

#include<cstdio>
#include<iostream>
#define db double
#define pc putchar
#define ll long long
#define Tp template<typename _T>
Tp _T mabs(_T a){ return a<0?-a:a; }
Tp _T mmax(_T a,_T b){ return a<b?b:a; }
Tp _T mmin(_T a,_T b){ return a<b?a:b; }
Tp void mswap(_T &a,_T &b){ _T t=a; a=b; b=t; return; }
using namespace std;
struct IO{
	char buf[1<<21],*p1,*p2;
	char gc(){ return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++; }
	IO & operator >> (char &x){ x=gc(); while(x=='\r'||x=='\n'||x==' ') x=gc(); return *this; }
	Tp IO & operator >> (_T &x){
		x=0; char c=gc(); bool f=0; while(c<'0'||c>'9'){ if(c=='-') f^=1; c=gc(); }
		while('0'<=c&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=gc(); f?x=-x:0; return *this;
	}
	int st[39],top;
	IO & operator << (char x) { pc(x); return *this; }
	Tp IO & operator << (_T x){
		if(x<0) x=-x,pc('-'); if(x==0){ pc('0'); return *this; }
		top=0; while(x) st[++top]=x%10,x/=10;
		while(top--) pc(st[top+1]+48); return *this;
	}
}fin;
#define maxn
ll s,c;
ll js(ll x){
	if(!x) return -1;
	ll k,l,ans;
	ans=x*c;
	k=(mmin(c*(c+1)/2,s)-x)/(c+1);
	l=k*(c+1)+x;
	ans+=(s+l+1)*(s-l)/2;
	ans+=(l+x+c+1)*k/2*c;
	return ans;
}
void work(){
	fin>>s>>c; if(c==1){ fin<<s*(s+1)/2<<'\n'; return; }
	if(s<=c){ fin<<c*s<<'\n'; return; }
	int i,ans=mmax(mmax(js(1),js((s+c)%(c+1))),mmax(mmax(js(s%(c+1)),js((s+1)%(c+1))),mmax(js(c-1),js(c))));
	fin<<ans<<'\n'; return;
}
int main(){
#ifdef LOCAL
	freopen("1.in","r",stdin);
	//freopen(".out","w",stdout);
#endif
	int T; fin>>T; while(T--) work(); return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3704kb

input:

4
1 2
2 1
10 4
172800 172800

output:

2
3
63
29859840000

result:

ok 4 tokens

Test #2:

score: -100
Wrong Answer
time: 4ms
memory: 4280kb

input:

100000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 ...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
...

result:

wrong answer 9506th words differ - expected: '237', found: '236'