QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#391042#6823. Coffee OverdoseNahidameowWA 0ms3752kbC++201.2kb2024-04-16 12:29:552024-04-16 12:29:56

Judging History

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

  • [2024-04-16 12:29:56]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3752kb
  • [2024-04-16 12:29:55]
  • 提交

answer

#include<bits/stdc++.h>
#define pd push_back
#define all(A) A.begin(),A.end()
#define lower_bound lb
#define ve std::vector
typedef long long ll;
typedef long long ll;
typedef __int128 Int;
typedef unsigned long long ul;
typedef long double LD;
bool FileIfstream(std::string name){
	std::ifstream f(name.c_str());
	return f.good();
}
namespace Math{
	ll QP(ll x,ll y,ll mod){ll ans=1;for(;y;y>>=1,x=x*x%mod)if(y&1)ans=ans*x%mod;return ans;}
	ll inv(ll x,ll mod){return QP(x,mod-2,mod);}
}
const int N=2e5+10;
const int mod=998244353;
void solve(){
	//don't forget to open long long
	ll S,C;std::cin>>S>>C;
	ll ans=0;
	auto get=[&](ll x)->ll{
		return x*C*(C-1)/2-C*x*(x-1)/2+S*(S+1)/2; 
	};
	auto calc=[&]()->ll{
		ll k=(S-1)/C,r=S-k*C;
		return k*C*(C-1)/2-(k-1)*k/2*C+C*r-r*(r+1)/2+S*(S+1)/2;
	};
	ans=calc();
	for(ll P=C/2-100;P<=C/2+100;P++)
		ans=std::max(ans,get(std::min(P,S/C)));
	std::cout<<ans<<'\n';
}
int main(){
#ifndef ONLINE_JUDGE
	if(!FileIfstream("IO.in")){
		freopen("IO.in","w",stdout);
		return 0;
	}
	freopen("IO.in","r",stdin);
	freopen("IO.out","w",stdout);
#endif
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);
	int T=1;
	std::cin>>T;
	while(T--)solve();

	return 0;
}




Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
1 2
2 1
10 4
172800 172800

output:

2
3
68
29859840000

result:

wrong answer 3rd words differ - expected: '63', found: '68'