A. Anti-knapsack

思路:首先比k大的都可以加进来。其次对于小于k的,检验当前集合里面有没有和他相加等于k的,没有的话就可以加进集合。这一步可以覆盖多个数相加的情况。

view code
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include <queue>
#include<sstream>
#include <stack>
#include <set>
#include <bitset>
#include<vector>
#define FAST ios::sync_with_stdio(false)
#define abs(a) ((a)>=0?(a):-(a))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mem(a,b) memset(a,b,sizeof(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define endl '\n'
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PII;
const int maxn = 1e5+200;
const int inf=0x3f3f3f3f;
const double eps = 1e-7;
const double pi=acos(-1.0);
const int mod = 1e9+7;
inline int lowbit(int x){return x&(-x);}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){d=a,x=1,y=0;}else{ex_gcd(b,a%b,d,y,x);y-=x*(a/b);}}//x=(x%(b/d)+(b/d))%(b/d);
inline ll qpow(ll a,ll b,ll MOD=mod){ll res=1;a%=MOD;while(b>0){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
inline ll inv(ll x,ll p){return qpow(x,p-2,p);}
inline ll Jos(ll n,ll k,ll s=1){ll res=0;rep(i,1,n+1) res=(res+k)%i;return (res+s)%n;}
inline ll read(){ ll f = 1; ll x = 0;char ch = getchar();while(ch>'9'||ch<'0') {if(ch=='-') f=-1; ch = getchar();}while(ch>='0'&&ch<='9') x = (x<<3) + (x<<1) + ch - '0', ch = getchar();return x*f; }
int dir[4][2] = { {1,0}, {-1,0},{0,1},{0,-1} }; int main()
{
int kase;
cin>>kase;
while(kase--)
{
ll n = read(), k = read();
vector<ll> ans;
rep(i,k+1, n) ans.pb(i);
per(i,k-1, 1)
{
int flag = 1;
for(int j=0; j<ans.size(); j++)
{
if(ans[j] + i == k)
{
flag = 0;
break;
}
}
if(flag) ans.pb(i);
}
cout<<ans.size()<<endl;
for(int i=0; i<ans.size(); i++) cout<<ans[i]<<' '; cout<<endl;
}
return 0;
}

B. Planet Lapituletti

思路:逐位模拟即可,注意一下细节。检验的时候注意:

1.镜像完肯定要是一个数字,满足的只有0->0, 1->1, 2->5, 5->2, 8->8。

2.镜像完分钟位和小时位是互换的。

详见代码

view code
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include <queue>
#include<sstream>
#include <stack>
#include <set>
#include <bitset>
#include<vector>
#define FAST ios::sync_with_stdio(false)
#define abs(a) ((a)>=0?(a):-(a))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mem(a,b) memset(a,b,sizeof(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define endl '\n'
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PII;
const int maxn = 1e5+200;
const int inf=0x3f3f3f3f;
const double eps = 1e-7;
const double pi=acos(-1.0);
const int mod = 1e9+7;
inline int lowbit(int x){return x&(-x);}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){d=a,x=1,y=0;}else{ex_gcd(b,a%b,d,y,x);y-=x*(a/b);}}//x=(x%(b/d)+(b/d))%(b/d);
inline ll qpow(ll a,ll b,ll MOD=mod){ll res=1;a%=MOD;while(b>0){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
inline ll inv(ll x,ll p){return qpow(x,p-2,p);}
inline ll Jos(ll n,ll k,ll s=1){ll res=0;rep(i,1,n+1) res=(res+k)%i;return (res+s)%n;}
inline ll read(){ ll f = 1; ll x = 0;char ch = getchar();while(ch>'9'||ch<'0') {if(ch=='-') f=-1; ch = getchar();}while(ch>='0'&&ch<='9') x = (x<<3) + (x<<1) + ch - '0', ch = getchar();return x*f; }
int dir[4][2] = { {1,0}, {-1,0},{0,1},{0,-1} }; ll h, m;
map<ll,ll> Map; PII nextTime(PII cur)
{
ll e = 0;
ll hour = cur.fi;
ll mi = cur.se;
mi += 1;
if(mi>=m) mi = 0, e = 1;
hour += e;
if(hour>=h) hour = 0;
PII ans;
ans.fi = hour;
ans.se = mi;
return ans;
} bool check(PII cur)
{
ll hour = cur.fi;
ll mi = cur.se;
vector<ll> mirrorMi;
vector<ll> mirrorH;
while(mi) mirrorMi.pb(mi%10), mi /= 10;
while(mirrorMi.size()<2) mirrorMi.pb(0); while(hour) mirrorH.pb(hour%10), hour /= 10;
while(mirrorH.size()<2) mirrorH.pb(0); int flag = 1;
for(int i=0; i<mirrorMi.size(); i++) if(mirrorMi[i]!=0&&!Map[mirrorMi[i]]) flag = 0;
for(int i=0; i<mirrorH.size(); i++) if(mirrorH[i]!=0&&!Map[mirrorH[i]]) flag = 0;
if(!flag) return false;
ll curM = Map[mirrorH[0]]*10+Map[mirrorH[1]];
ll curH = Map[mirrorMi[0]]*10 + Map[mirrorMi[1]];
if(curH<h&&curM<m) return true;
return false;
} int main()
{
Map[0] = 0;
Map[1] = 1;
Map[2] = 5;
Map[5] = 2;
Map[8] = 8;
int kase;
cin>>kase;
while(kase--)
{
h = read(), m = read();
PII cur;
scanf("%lld:%lld",&cur.fi, &cur.se);
while(1)
{
if(check(cur)) break;
cur = nextTime(cur);
}
printf("%02lld:%02lld\n",cur.fi,cur.se);
}
return 0;
}

Codeforces Round #705 (Div. 2) AB题解的更多相关文章

  1. # Codeforces Round #529(Div.3)个人题解

    Codeforces Round #529(Div.3)个人题解 前言: 闲来无事补了前天的cf,想着最近刷题有点点怠惰,就直接一场cf一场cf的刷算了,以后的题解也都会以每场的形式写出来 A. Re ...

  2. Codeforces Round #557 (Div. 1) 简要题解

    Codeforces Round #557 (Div. 1) 简要题解 codeforces A. Hide and Seek 枚举起始位置\(a\),如果\(a\)未在序列中出现,则对答案有\(2\ ...

  3. Codeforces Round #540 (Div. 3) 部分题解

    Codeforces Round #540 (Div. 3) 题目链接:https://codeforces.com/contest/1118 题目太多啦,解释题意都花很多时间...还有事情要做,就选 ...

  4. Codeforces Round #538 (Div. 2) (A-E题解)

    Codeforces Round #538 (Div. 2) 题目链接:https://codeforces.com/contest/1114 A. Got Any Grapes? 题意: 有三个人, ...

  5. Codeforces Round #531 (Div. 3) ABCDEF题解

    Codeforces Round #531 (Div. 3) 题目总链接:https://codeforces.com/contest/1102 A. Integer Sequence Dividin ...

  6. Codeforces Round #527 (Div. 3) ABCDEF题解

    Codeforces Round #527 (Div. 3) 题解 题目总链接:https://codeforces.com/contest/1092 A. Uniform String 题意: 输入 ...

  7. Codeforces Round #499 (Div. 1)部分题解(B,C,D)

    Codeforces Round #499 (Div. 1) 这场本来想和同学一起打\(\rm virtual\ contest\)的,结果有事耽搁了,之后又陆陆续续写了些,就综合起来发一篇题解. B ...

  8. Codeforces Round #713 (Div. 3)AB题

    Codeforces Round #713 (Div. 3) Editorial 记录一下自己写的前二题本人比较菜 A. Spy Detected! You are given an array a ...

  9. Codeforces Round #545 (Div. 1) 简要题解

    这里没有翻译 Codeforces Round #545 (Div. 1) T1 对于每行每列分别离散化,求出大于这个位置的数字的个数即可. # include <bits/stdc++.h&g ...

  10. Codeforces Round #624 (Div. 3)(题解)

    Codeforces Round #624 (Div.3) 题目地址:https://codeforces.ml/contest/1311 B题:WeirdSort 题意:给出含有n个元素的数组a,和 ...

随机推荐

  1. Windows端口号操作

    1.查看所有端口号:netstat -ano 2.查看端口号:netstat -ano | findstr "16888" 3.杀死进程:taskkill /f /pid 8524

  2. Asp.net mvc基础(一):Razor语法

    1.使用@{C#代码区域},调用@C#代码 2.使用@调用foreach,for,if等语句 2.在foreach,for,if等语句中使用汉字会报错,原因是在代码中纯文字会被认为是C#代码 如下: ...

  3. 康谋分享 | 自动驾驶联合仿真——功能模型接口FMI(终)

    在之前的文章中,我们介绍了如何构建简单的车辆模型,并基于FMI2.0构建了其FMU,其最终结构为: 今天将会和大家分享如何在aiSim中,通过UDP和aiSim车辆动力学API(Vehicle Dyn ...

  4. 什么是 Java 的 AOT(Ahead-Of-Time)?

    Java 的 AOT(Ahead-Of-Time) 1. 定义 AOT(Ahead-Of-Time)编译是与 JIT(Just-In-Time)相对的一种编译方式. 在 AOT 模式下,Java 字节 ...

  5. Result、ConfigAwait、ValueTask

    Result.ConfigAwait.ValueTask 参照: C# Async/Await: ConfigAwait, ValueTask是个啥?对提高性能有用么?_哔哩哔哩_bilibili 理 ...

  6. Java单例模式:从实战到面试的深度解析

    结论先行 饿汉式:线程安全但可能造成资源浪费,推荐在初始化成本低的场景使用 懒汉式:需要解决线程安全问题,推荐使用双重检查锁+volatile优化 静态内部类:最佳实践方案,完美平衡延迟加载与线程安全 ...

  7. 2025.3.24 DP专题

    题目按照主观难度增序排列 Luogu P1758 [NOI2009] 管道取珠 有上下两个长度分别为 \(n,m\) 的管道 \(a,b\),管道中有两种不同颜色的球用 \(A,B\) 表示.现在每次 ...

  8. Spring--IOC注解用法初探

    创建一个UserDao接口,和一个UserDaoImp的实现类 UserDao接口 package com.zjw.spring.demo1; public interface UserDao { p ...

  9. skip

    哇酷哇酷,和你的春天一样稍纵即逝的夏天 藏什么藏呢 自卑吗 你以为是缺点的 恰恰让我喜欢 但要短确实很短 说难是很难 而且烂 恰到好处吧 好男人也没的身手! 为了足以被好男人拯救 我在练习 结果是腿废 ...

  10. Qt图像处理技术六:拉普拉斯锐化

    Qt图像处理技术六:拉普拉斯锐化 效果图 源码 由该公式得到下方卷积核 使用到的卷积核: //都把QImage转化为rgb888更好运算 QImage LaplaceSharpen(const QIm ...