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. leetcode001 两数之和

    问题描述:两数之和 给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标. 你可以假设每种输入只会对应一个答 ...

  2. vscode配置xdebug断点调试thinkphp

    vscode配置xdebug断点调试thinkphp其实和配置其他php框架的断点调试一样,步骤如下: 下载xdebug,重命名为php_xdebug.dll并移动到php.ini目录: (不知道下载 ...

  3. html input 是否允许浏览器字段默认值 或者之前输入的值

    autocomplete 属性是 HTML5 中的新属性,在input中autocomplete属性是默认开启的. 1.定义:autocomplete属性规范表单是否启用自动完成功能.自动完成允许浏览 ...

  4. 拆解 Cursor Pro 自动化工具,看看它是怎么实现的?

    深入解析Cursor Pro自动化工具的核心实现 ‍ 从源码角度剖析关键技术 完整解读:注册.认证.机器码重置的自动化方案 项目概述 大家好,我是松哥.这篇文章将为大家详细解析一个Cursor自动化管 ...

  5. 如何创建一个 Win32 窗口并理解其背后的设计

    如何创建一个 Win32 窗口并理解其背后的设计 在 Windows 系统中,使用 Win32 API 创建图形用户界面(GUI)应用程序是传统的做法.虽然现在有许多更高层次的开发框架,比如 MFC. ...

  6. ARM终端 KylinOS 容器镜像导入排障

    背景信息 电脑:华为擎云L420 CPU:ARM架构,HUAWEI Kirin 9006C OS:Kylin桌面操作系统V10(SP1) Kernel:5.4.96 Docker: 27.5.1 已准 ...

  7. 双向 和 多重 RNN

    前面已经对 RNN (递归神经网络) 的变体 (主要为解决 梯度消失和梯度爆炸) 接触了两个比较流行的 LSTM 和 GRU, 其核心思想呢, 是通过其所谓 **"gate" ** ...

  8. 转-Linux mpstat命令入门-CPU实时监控详解

    简介   mpstat 来自Multiprocessor Statistics的英文缩写,是实时系统监控工具,主要用来查看多CPU系统中每个CPU的负载是否均衡,相关统计信息存放在/proc/stat ...

  9. mac ssh 总是自动断开

    创建一个ssh配置文件: vi ~/.ssh/config 写入以下内容: Host * ServerAliveInterval 120 TCPKeepAlive no

  10. 解决DevToolsActivePort file doesn't exist

    今天遇到个小问题:selenium 启动 chrome crash,报错:DevToolsActivePort file doesn't exist. 在option中添加一下几行: option = ...