码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • Codeforces Round 952 (Div. 4)(实时更新)


    A - Creating Words

    题意:略

    代码:

    1. #include
    2. #define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)//不能使用scanf了
    3. #define int long long
    4. #define loop(n) for(int i=0;i
    5. #define rloop(n) for(int i=n-1;i>=0;i--)
    6. #define print(c) cout<<"this "#c" is "<
    7. #define MAX INT_MAX
    8. #define MIN INT_MIN
    9. const int N=1010;
    10. using namespace std;
    11. void solve() {
    12. string a,b;cin>>a>>b;
    13. char c=a[0];
    14. a[0]=b[0];
    15. b[0]=c;
    16. cout<' '<
    17. }
    18. signed main() {
    19. ios;
    20. int n=1;
    21. cin >> n;
    22. while (n--)solve();
    23. }

    B - Maximum Multiple Sum

    题意:略

    代码:

    1. #include
    2. #define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
    3. #define int long long
    4. #define loop(n) for(int i=0;i
    5. #define rloop(n) for(int i=n-1;i>=0;i--)
    6. #define print(c) cout<<"this "#c" is "<
    7. #define MAX INT_MAX
    8. #define MIN INT_MIN
    9. #define N 1e6+10
    10. using namespace std;
    11. void solve() {
    12. int n;cin>>n;
    13. auto check=[&](int t){
    14. int i=2;
    15. for(;i<=sqrt(t);i++)
    16. if(t%i==0)break;
    17. if(i>=sqrt(t))return 1;
    18. else return 0;
    19. };
    20. if(n<4)cout<
    21. else cout<<2<
    22. }
    23. signed main() {
    24. ios;
    25. int n=1;
    26. cin >> n;
    27. while (n--)solve();
    28. }

    C - Good Prefixes

    题意:给数组a[n],然后定义数组的2*max=sum,则认为这个数组是好数组

            我们求sum和max,然后比较即可,可以用递推优化

    代码:

    1. #include
    2. #define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
    3. #define int long long
    4. #define loop(n) for(int i=0;i
    5. #define rloop(n) for(int i=n-1;i>=0;i--)
    6. #define print(c) cout<<"this "#c" is "<
    7. #define MAX INT_MAX
    8. #define MIN INT_MIN
    9. #define N 1e6+10
    10. using namespace std;
    11. void solve() {
    12. int n; cin>>n;
    13. int a[n]; loop(n)cin>>a[i];
    14. int S[n],Max[n];
    15. loop(n){
    16. if(i==0)S[i]=a[i],Max[i]=a[i];
    17. else S[i]=S[i-1]+a[i],Max[i]=max(Max[i-1],a[i]);
    18. }
    19. int count=0;
    20. loop(n)
    21. if(S[i]==2*Max[i])count++;
    22. cout<
    23. }
    24. signed main() {
    25. ios;
    26. int n=1;
    27. cin >> n;
    28. while (n--)solve();
    29. }

    D - Manhattan Circle

    题意:找圆的圆心

    代码:

    1. #include
    2. #define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
    3. #define int long long
    4. #define loop(n) for(int i=0;i
    5. #define rloop(n) for(int i=n-1;i>=0;i--)
    6. #define print(c) cout<<"this "#c" is "<
    7. #define MAX INT_MAX
    8. #define MIN INT_MIN
    9. #define N 1e6+10
    10. using namespace std;
    11. void solve() {
    12. int n,m;cin>>n>>m;
    13. char a[n][m];
    14. int line=n-1,num=0,first=0;
    15. for(int i=0;i
    16. for(int j=0;j
    17. cin>>a[i][j];
    18. for(int i=0,count=0,k=0;i0){
    19. for(int j=0;j
    20. if(a[i][j]=='#')count++;
    21. }
    22. if(count==2*k+1)k++;
    23. else if(k!=0){
    24. line=i-1,num=count==0?1:count+2;
    25. break;
    26. }
    27. //如果在最后一行,line不会赋值,则line的初始值设为n-1
    28. }
    29. loop(m)if(a[line][i]=='#'){
    30. first=i;break;
    31. }
    32. cout<1<<' '<2+1<
    33. }
    34. signed main() {
    35. ios;
    36. int n=1;
    37. cin >> n;
    38. while (n--)solve();
    39. }

  • 相关阅读:
    node 第七天 手写前后端jsonp(一个古老的绕过跨域的方法)
    Visual Studio 如何把一个解决方案中已经打开的选项页在另一个解决方案中打开
    图象的感光原件、成象原理、相机的相关坐标系
    论文的写作
    每日一问:Java中接口和抽象类的区别
    vscode在资源管理器中进行查询 vscode 查找文件名 ctrl + P
    直播预约:人人都是数字化设计师
    Redis的全局命令及相关误区
    自然语言处理的多行业应用
    信息系统项目管理师第四版学习笔记——项目管理科学基础
  • 原文地址:https://blog.csdn.net/weixin_73164943/article/details/139627083
  • 最新文章
  • 沪漂五周年了:我越来越迷茫了
    Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
    MySQL-Seconds_behind_master的精度误差
    [MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
    AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
    Agent OS :五种驯服不确定性的范式
    PortSwigger SQL注入LAB11
    数据库即时编译JIT
    [Begin]AI Learn Data Day 0
    深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号