2021-10-03 20:00 ATCoder周赛
2021-10-03 20:00 ATCoder周赛
A 略
B 略
C - Select Mul
Problem Statement
You are given an integer N. Consider permuting the digits in N and separate them into two positive integers.
For example, for the integer 123, there are six ways to separate it, as follows:
- 12 and 3,
- 21 and 3,
- 13 and 2,
- 31 and 2,
- 23 and 1,
- 32 and 1.
Here, the two integers after separation must not contain leading zeros. For example, it is not allowed to separate the integer 101 into 1 and 01. Additionally, since the resulting integers must be positive, it is not allowed to separate 101 into 11 and 0, either.
What is the maximum possible product of the two resulting integers, obtained by the optimal separation?
- N is an integer between 1 and 10^9(inclusive).
- N contains two or more digits that are not 0.
Constraints
- 1≤N≤105
- 1≤Ai≤109
- 1≤X≤1018
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
Output
Print the maximum possible product of the two integers after separation.
AC代码
#include <bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i=(l);i<(r);++i)
typedef long long ll;
int main(){
string s;
cin>>s;
sort(s.rbegin(),s.rend());
string a,b;
rep(i,0,(int)s.size()){
if(i%2==0) a+=s[i];
else b+=s[i];
}
rep(i,0,(int)min(a.size(),b.size())){
if(a[i]!=b[i]){swap(a[i],b[i]); break;}
}
cout<<stoi(a)*stoi(b)<<endl;
}
D - FG operation
Problem Statement
There is an online game with N registered players.
Today, which is the 10^100-th day since its launch, the developer Takahashi examined the users' login history. It turned out that the i-th player logged in for Bi consecutive days from Day Ai , where Day 1 is the launch day, and did not log in for the other days. In other words, the i-th player logged in on Day Ai, Ai+1, …, Ai +Bi−1, and only on those days.
For each integer k such that 1≤k≤N, find the number of days on which exactly k players logged in.
Constraints
- 1≤N≤2×10^5
- 1≤Ai≤10^9
- 1≤Bi≤10^9
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
A1 B1
...
AN BN
Output
D1
D2
⋯
Dn
Here, Di denotes the number of days on which exactly k players logged in.
AC代码
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int N = 200010;
typedef pair<int,int> pii;
#define rep(i,n) for(int i = 1; i <= n; ++i)
int main()
{
int n, a, b;
cin >> n;
vector<pii>x;
int ans[N];
rep(i,N) ans[i] = 0;
ans[0] = 0;
rep(i,n)
{
cin >> a >> b;
x.push_back({a, 1});
x.push_back({a + b, -1});
}
sort(x.begin(), x.end());
int cnt = 0;
for(int i = 0; i < x.size() - 1; ++i)
{
cnt += x[i].second;
ans[cnt] += x[i+1].first - x[i].first;
}
rep(i, n-1) cout << ans[i] <<" ";
cout << ans[n] << endl;
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?