• T1
  • T2
  • T3
  • T4

这场难度非常鬼畜.

T1

暴力枚举判断幸运数字以及是否整除.2分钟搞定.

#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){re0 x=0,f=1;rec c=gc();for (;!isdigit(c);c=gc()) f^=c=='-';for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');return f?x:-x;}
inline void read(rel &x){x=0;re0 f=1;rec c=gc();for (;!isdigit(c);c=gc()) f^=c=='-';for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');x=f?x:-x;}
template <typename mitsuha>
inline int write(mitsuha x){if (!x) return pc(48);if (x<0) x=-x,pc('-');re0 bit[20],i,p=0;for (;x;x/=10) bit[++p]=x%10;for (i=p;i;--i) pc(bit[i]+48);}
inline char fuhao(){rec c=gc();for (;isspace(c);c=gc());return c;}
}using namespace chtholly;
using namespace std;
int n=read();int is_lucky(int n){
for (;n;n/=10){int t=n%10;if (t!=7&&n!=4) return 0;}return 1;
}int main(){
for (int i=4;i<=n;++i) if (is_lucky(i)&&n%i==0) return puts("YES"),0;
puts("NO");
}

T2

其实就是判断字符串"4"和"7"哪种比较多.我暴力枚举用了string的substr()函数,用错了Wa了两发.

#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){re0 x=0,f=1;rec c=gc();for (;!isdigit(c);c=gc()) f^=c=='-';for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');return f?x:-x;}
inline void read(rel &x){x=0;re0 f=1;rec c=gc();for (;!isdigit(c);c=gc()) f^=c=='-';for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');x=f?x:-x;}
template <typename mitsuha>
inline int write(mitsuha x){if (!x) return pc(48);if (x<0) x=-x,pc('-');re0 bit[20],i,p=0;for (;x;x/=10) bit[++p]=x%10;for (i=p;i;--i) pc(bit[i]+48);}
inline char fuhao(){rec c=gc();for (;isspace(c);c=gc());return c;}
}using namespace chtholly;
using namespace std;
string s;int is_lucky(int l,int r){
for (int i=l;i<=r;++i) if (s[i]!='4'&&s[i]!='7') return 0;
return 1;
}int find(int k,string a){
int t=s.find(a,k);
if (t==-1) return 0;
return find(t+1,a)+1;
}int main(){
cin>>s;
int ans=-1;
string res;
for (int i=0;i<=s.size();++i){for (int j=i;j<=s.size();++j){if (is_lucky(i,j)&&s.substr(i,j-i+1)!=""){int tmp=find(0,s.substr(i,j-i+1));if (tmp>ans){res=s.substr(i,j-i+1);ans=tmp;}else if (tmp==ans&&s.substr(i,j-i+1)<res){res=s.substr(i,j-i+1);}} }}
if (!~ans) puts("-1");
else cout<<res;
}

T3

[l,r]区间里大于或者等于每一个数的最小幸运数字之和.
可以发现对于两个幸运数字之间的数字,它们的next函数值都是相同的.我们对询问进行分块.
先dfs预处理所有幸运数字,然后一个一个去跑就可以了.
预处理幸运数字要处理到10位,否则会炸.

#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){re0 x=0,f=1;rec c=gc();for (;!isdigit(c);c=gc()) f^=c=='-';for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');return f?x:-x;}
inline void read(rel &x){x=0;re0 f=1;rec c=gc();for (;!isdigit(c);c=gc()) f^=c=='-';for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');x=f?x:-x;}
template <typename mitsuha>
inline int write(mitsuha x){if (!x) return pc(48);if (x<0) x=-x,pc('-');re0 bit[20],i,p=0;for (;x;x/=10) bit[++p]=x%10;for (i=p;i;--i) pc(bit[i]+48);}
inline char fuhao(){rec c=gc();for (;isspace(c);c=gc());return c;}
}using namespace chtholly;
using namespace std;
const int mulu=2e5;
ll ans,lnum[mulu],cnt,l=read(),r=read();void dfs(int k,ll num){
if (!k) return void(lnum[++cnt]=num);
dfs(k-1,num*10+4);
dfs(k-1,num*10+7);
}void pre(){
int i;
for (i=1;i<=10;++i) dfs(i,0);
sort(lnum+1,lnum+cnt+1);
}int main(){
re0 i;
pre();
for (;l<=r;){int pos=lower_bound(lnum+1,lnum+cnt+1,l)-lnum;ans+=(min(r,lnum[pos])-l+1)*lnum[pos];l=lnum[pos]+1;}
write(ans);
}

T4

滑稽模拟.
直接看样例就可以找出规律.一旦碰到"447"或者477再符合一些玄学条件就可以无限操作下去.
其他情况只能操作一次.最后判断一下k的奇偶性决定这一位是4或者7即可.

#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){re0 x=0,f=1;rec c=gc();for (;!isdigit(c);c=gc()) f^=c=='-';for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');return f?x:-x;}
inline void read(rel &x){x=0;re0 f=1;rec c=gc();for (;!isdigit(c);c=gc()) f^=c=='-';for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');x=f?x:-x;}
template <typename mitsuha>
inline int write(mitsuha x){if (!x) return pc(48);if (x<0) x=-x,pc('-');re0 bit[20],i,p=0;for (;x;x/=10) bit[++p]=x%10;for (i=p;i;--i) pc(bit[i]+48);}
inline char fuhao(){rec c=gc();for (;isspace(c);c=gc());return c;}
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
int n=read(),k=read();
char c[yuzu|10];
int main(){
int i;
scanf("%s",c+1);
for (i=1;i<n&&k;++i){if (c[i]=='4'&&c[i+1]=='7'){k--;if (i&1){c[i+1]='4';if (c[i+2]=='7'){c[i+1]=k&1?'7':'4';k=0;}}else{c[i]='7';if (c[i-1]=='4'){c[i]=k&1?'4':'7';k=0;}}}}
puts(c+1);
}

Codeforces Beta Round #91 div.2 滑稽场 A-D相关推荐

  1. Codeforces Beta Round #75 (Div. 1 Only) B. Queue 线段树。单点更新

    http://codeforces.com/problemset/problem/91/B 题意: 给你n个数,求得i 到n中小于a[i]的最右边的a[j],然后求a[i]到a[j]之间包含了多少个数 ...

  2. Codeforces Beta Round #22 (Div. 2 Only) E. Scheme(DFS+强连通)

    题目大意 给了 n(2<=n<=105) 个点,从每个点 u 出发连向了一个点 v(共 n 条边) 现在要求添加最少的边使得整个图是一个强连通图 做法分析 这道题千万不要一般化:先求强连通 ...

  3. Codeforces Beta Round #4 (Div. 2 Only)

    Codeforces Beta Round #4 (Div. 2 Only) A 水题 1 #include<bits/stdc++.h> 2 using namespace std; 3 ...

  4. Codeforces Beta Round #92 (Div. 1 Only) A. Prime Permutation 暴力

    A. Prime Permutation 题目连接: http://www.codeforces.com/contest/123/problem/A Description You are given ...

  5. Codeforces Beta Round #9 (Div. 2 Only) D. How many trees? dp

    D. How many trees? 题目连接: http://www.codeforces.com/contest/9/problem/D Description In one very old t ...

  6. Codeforces Beta Round #14 (Div. 2) B. Young Photographer 水题

    B. Young Photographer 题目连接: http://codeforces.com/contest/14/problem/B Description Among other thing ...

  7. Codeforces Beta Round #96 (Div. 1) D. Constants in the language of Shakespeare 贪心

    D. Constants in the language of Shakespeare Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codef ...

  8. Codeforces Beta Round #9 (Div. 2 Only) C. Hexadecimal's Numbers dfs

    C. Hexadecimal's Numbers 题目连接: http://www.codeforces.com/contest/9/problem/C Description One beautif ...

  9. Codeforces Beta Round #16 (Div. 2 Only)【未完结】

    2022.3.9 题目地址:https://codeforces.com/contest/16 目录 A. Flag[模拟] B. Burglar and Matches[贪心] C. Monitor ...

最新文章

  1. LeetCode——Rotate Image(二维数组顺时针旋转90度)
  2. 【Android 逆向】Android 中常用的 so 动态库 ( /system/lib/libc.so 动态库 | libc++.so 动态库 | libstdc++.so 动态库 )
  3. AS打开速度慢,AS项目导入慢,新建项目导入慢
  4. Redis应用案例 查找某个值的范围
  5. Bug调试(lldb)
  6. 怎么设置tomcat的默认应用
  7. android studio 修改文件后出现类型转换错误
  8. 《设计模式详解》软件设计原则
  9. android 进程(复习)
  10. C#关键字=四六级核心词汇
  11. win32com模块
  12. 类818tu.c微信小说分销系统设计之定时模板消息源码
  13. scipy的安装教程
  14. 图解机器学习算法(3) | KNN算法及其应用(机器学习通关指南·完结)
  15. php投影,投影效果怎么做?PS制作逼真的投影效果
  16. 研究鸟类迁徙的目的和意义
  17. 每日一坑:不支援 10 验证类型。请核对您已经组态 pg_hba.conf 文件包含客户端的IP位址或网路区段,以及驱动程序所支援的验证架构模式已被支援。
  18. 计算机考研院校排名2015,2015年计算机考研学校排名
  19. Cisco与H3C交换机互联的小风波
  20. 深入理解JVM(三)——JVM之判断对象是否存活(引用计数算法、可达性分析算法,最终判定),Eclipse设置GC日志输出,引用

热门文章

  1. 隐式超级构造函数Fu()未定义。
  2. Windows系统剪切板不可用
  3. 2022年MacBook Air全新设计
  4. Latex 设置 字体大小 算法伪代码的字体大小
  5. 20221130 RabbitMQ
  6. 聊聊获取屏幕高度这件事
  7. woj4764 子矩阵
  8. Optic Disc Detection using Template Matching based on Color Plane Histograms
  9. 英特尔下一代服务器cpu消息,向10nm转型 英特尔下一代CPU与GPU前瞻
  10. 106短信验证码发送不出去是因为什么原因