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. Clion配置Fortran环境

    1.安装CLion 下载链接:https://www.jetbrains.com/ 下载好后安装到指定目录即可 2.安装Fortran插件 3.编写程序 1)打开CLion,新建一个Fortran项目 ...

  2. 🎀chrome-网页gif截图插件

    简介 本文介绍网页中gif截图工具使用,便于日常对网页中动态效果或元素进行截图 软件介绍 Capture to a Gif 是用来录制屏幕并将其保存为 GIF 格式文件的chrome插件工具.它允许用 ...

  3. QT 的信号-槽机制

    对于对象间的通信问题,很多框架采用回调函数类解决.QT 使用信号-槽解决对象间的通信问题,只要继承 QObject 类就可以使用信号-槽机制.信号-槽使用起来非常简单.灵活,发射和接收对象实现了解耦. ...

  4. Sentinel源码—7.参数限流和注解的实现

    大纲 1.参数限流的原理和源码 2.@SentinelResource注解的使用和实现 1.参数限流的原理和源码 (1)参数限流规则ParamFlowRule的配置Demo (2)ParamFlowS ...

  5. git 更新和强制更新失败

    Your local changes to the following files would be overwritten by mergeerror: Your local changes to ...

  6. 我与 ChatGPT 讨论了面向对象语言 中,关于动态调用的问题

    你好,支持面向对象的语言中,"方法表" 是用来处理什么的? 在面向对象的语言中,"方法表"通常指一个类或对象中定义的方法列表.这些方法定义了该类或对象可以做什么 ...

  7. AD 侦查-MSRPC Over SMB

    本文通过 Google 翻译 AD Recon – MSRPC Over SMB (135/139/445) 这篇文章所产生,本人仅是对机器翻译中部分表达别扭的字词进行了校正及个别注释补充. 导航 0 ...

  8. vue3 基础-列表渲染

    本篇讲列表渲染, 主要是对 v-on 指令配合 v-if 和一些数组相关的方法来体验 vue 的模板渲染方法. 数组元素的渲染 <!DOCTYPE html> <html lang= ...

  9. 网络编程:UDP网路编程

    参考:盛延敏:网络编程实战 一.UDP和TCP的不同 UDP 是一种"数据报"协议,而 TCP 是一种面向连接的"数据流"协议. TCP 是一个面向连接的协议, ...

  10. 补充停牌的日K数据

    问题 从TuShare获取的数据,停牌日是没有数据的,这将会在回测时,不能直接参与账户的净值计算,导致账户的净值以及收益计算不准确. 停盘 股票由于某种消息或进行某种活动引起股价的连续上涨或下跌,由证 ...