A.签到题,用map嵌个结构体。
B.对于
C.直接暴力做,但用map被卡常,而数据又有点大
D.先处理好env
,然后对于每个问询,先算出
A
:
struct A
{
int c,j,z;
};
LL t;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>t;
f(sb,1,t){
map<char ,A> m;
f(i,1,15){
char na,nb;
int a,b,c,d;
cin>>na>>nb>>a>>b>>c>>d;
if(a>b){
m[na].c+=3,m[na].j+=(a-b),m[na].z+=a;
m[nb].j+=(b-a),m[nb].z+=b;
}
else if(a==b){
m[na].c+=1,m[na].j+=(a-b),m[na].z+=a;
m[nb].c+=1,m[nb].j+=(b-a),m[nb].z+=b;
}
else{
m[nb].c+=3,m[na].j+=(a-b),m[na].z+=a;
m[nb].j+=(b-a),m[nb].z+=b;
}
a=c,b=d;
if(a>b){
m[na].c+=3,m[na].j+=(a-b),m[na].z+=a;
m[nb].j+=(b-a),m[nb].z+=b;
}
else if(a==b){
m[na].c+=1,m[na].j+=(a-b),m[na].z+=a;
m[nb].c+=1,m[nb].j+=(b-a),m[nb].z+=b;
}
else{
m[nb].c+=3,m[na].j+=(a-b),m[na].z+=a;
m[nb].j+=(b-a),m[nb].z+=b;
}
}
f(i,0,5){
char d='A'+i;
cout<<m[d].c<<" "<<m[d].j<<" "<<m[d].z<<"\n";
}
}
return 0;
}
B
:
LL tt, n, m, r, c, v;
int main()
{
while (scanf("%lld%lld%lld%lld%lld", &n, &m, &r, &c, &v) == 5)
{
if (r * c <= v && n * m - v + 1 >= (n - r + 1) * (m - c + 1))
{
cout << "Yes\n";
}
else
cout << "No\n";
}
return 0;
}
C
:
LL n, x;
int main()
{
while (scanf("%lld", &n) == 1)
{
vi tar, a;
f(i, 0, n - 1) scanf("%lld", &x), tar.pb(2 * x), a.pb(x);
for (auto s = tar.begin(); s != tar.end();)
{
int flag = 1;
f(i, 0, n-1)
{
if (2 * a[i] != *s)
{
auto dd = lower_bound(all(a), *s - a[i]);
if (dd != a.end() && *dd == *s - a[i])
{
s = tar.erase(s);
flag = 0;
break;
}
}
}
if (flag)
s += 1;
}
cout<<n-tar.size() << "\n";
}
return 0;
}
D
:
const LL pp = 1e9 + 7,N=1e6+9;
LL n, m,env[N];
LL pow_mod(LL a, LL b, LL p)
{
LL ret = 1;
while (b)
{
if (b & 1)
ret = (ret * a) % p;
a = (a * a) % p;
b >>= 1;
}
return ret;
}
LL Fermat(LL a, LL p)
{
return pow_mod(a, p - 2, p);
}
int main()
{
f(i,1,1e6){
env[i]=Fermat(i,pp);
}
while (scanf("%lld%lld", &n, &m) == 2)
{
LL ans=0,te;
te = 1;
f(i, 1, m)
{
te *= i;
te %= pp;
}
ans += te;
ans %= pp;
f(j, 1, n - 1)
{
te *= env[j];
te %= pp;
te *= (j + m);
te %= pp;
ans += te;
ans %= pp;
}
cout << ans << "\n";
}
return 0;
}