A题纯属签到题目:
https://codeforces.com/contest/1622/problem/A
简述题意给定三个木棒让我们折断一个将其变成长方形问是否可以?(木棒只能折断成整数)
1.折断最大值:使得其和小的两根一致pd c=a+b:–当然看到tourist佬判断三个也可以
2.可能出现两个相等的这样有可能出现第三个不能被2整除的情况判断一下即可。
AC代码:
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <sstream>
#include <cstring>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <unordered_set>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<int, PII> PIII;
typedef pair<double, double> PDD;
const int N = 1e6 + 10, M = 2 * 100010, inf = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-5;
#define x first
#define y second
#define gcd __gcd
#define sr string
#define sn scanf("%d%d",&n,&m);
#define mh memset(h,-1,sizeof h),idx=0;
#define lcm(a, b) (a/gcd(a,b))*b;
int dir[4][2] = {{-1, 0},
{0, 1},
{1, 0},
{0, -1}};
int e[M], ne[M], h[N], idx, w[M], z[M];
int n, m, p[N], k, t, res, dfn[N], low[N], tot, id[N], T;
bool st[210][210], flag;
int root;
unordered_map<sr, int> q;
PII cp[3005];
bool cmp(PII W,PII C)
{
if (W.x==C.x) return W.y<C.y;
return W.x<C.x;
}
int main() {
cin>>T;
while (T--)
{
int a,b,c;
cin>>a>>b>>c;
n= min(a, min(b,c));
m= max(a, max(b,c));
k=a+b+c-n-m;
if (k+n==m||a==b&&c%2==0||a==c&&b%2==0||b==c&&a%2==0)
puts("YES");
else
puts("NO");
}
return 0;
}
B题读懂应该也是签到题目https://codeforces.com/contest/1622/problem/B
简述题意:本来给定一个打分表,让我们取修改这个打分表使得它满足一些性质
first:使得每个s串中的0要比1的打分要低
second:他还要是一个排列
使得|pi-qi]最小
我们需要从题目索取一些性质来用:
1.0的打分将是1.....m:m指的是0的个数
2.为了使得差值绝对值最小可以对pi进行排序小的剪小的差的绝对值相对来说较小
只需先处理0的从1.。m然后在处理1的依次排序输出即可
AC代码:
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <sstream>
#include <cstring>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <unordered_set>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<int, PII> PIII;
typedef pair<double, double> PDD;
const int N = 2e5 + 10, M = 2 * 100010, inf = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-5;
#define x first
#define y second
#define gcd __gcd
#define sr string
#define sn scanf("%d%d",&n,&m);
#define mh memset(h,-1,sizeof h),idx=0;
#define lcm(a, b) (a/gcd(a,b))*b;
int dir[4][2] = {{-1, 0},
{0, 1},
{1, 0},
{0, -1}};
int e[M], ne[M], h[N], idx, w[M], z[M];
int n, m, p[N], k, t, res, dfn[N], low[N], tot, id[N], T;
bool st[N], flag;
int root;
unordered_map<sr, int> q;
PII cp[3005];
int main() {
cin>>T;
while (T--)
{m=1;
cin>>n;
vector<int> res(n,0);
sr s;
for(int i=0;i<n;i++)
cin>>h[i];
cin>>s;
for(int x=0;x<=1;x++)
{ vector<PII> a;
for(int i=0;i<s.size();i++)
if (s[i]-'0'==x)
a.emplace_back(h[i],i);
sort(a.begin(),a.end());
for(auto &x:a)
res[x.y]=m++;
}
for(int i=0;i<n;i++)
cout<<res[i]<<" ";
cout<<endl;
}
return 0;
}
C题我觉得是数学题
只推个公式枚举y即可
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <sstream>
#include <cstring>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <unordered_set>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<int, PII> PIII;
typedef pair<double, double> PDD;
const int N = 2e5 + 10, M = 2 * 100010, inf = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-5;
#define x first
#define y second
#define gcd __gcd
#define sr string
#define sn scanf("%d%d",&n,&m);
#define mh memset(h,-1,sizeof h),idx=0;
#define lcm(a, b) (a/gcd(a,b))*b;
int dir[4][2] = {{-1, 0},
{0, 1},
{1, 0},
{0, -1}};
int e[M], ne[M], h[N], idx, w[M], z[M];
int n, m, p[N], k, t, res, dfn[N], low[N], tot, id[N], T;
bool st[N], flag;
int root;
unordered_map<sr, int> q;
LL a[N],s[N];
LL solve(LL a, LL b) {
LL c = (a) / b;
while (c * b > a)
c--;
return c;
}
int main() {
cin>>T;
while (T--)
{
LL k;
cin>>n>>k;
LL res=1e18;
memset(s,0,sizeof s);
for(int i=1;i<=n;i++)
cin>>a[i];
sort(a+1,a+n+1);
for(int i=1;i<=n;i++)
s[i]=s[i-1]+a[i];//前缀和
//枚举y的位置
for(int y=1;y<=n;y++)
{
LL x=a[1] - solve(k - s[y] + a[1], n-y+1 );
res= min(res, max(0LL,x)+n-y);
}
cout<<res<<endl;
}
return 0;
}
c题的公式后面的t的意义就变了,不然公式就推错了
我写漏了
不管了就那样吧!顺着上面正常人应该都能退下来