当前位置: 首页 > ai >正文

cf每日刷题c++

目录

Square Year(800)

 Not Quite a Palindromic String(900)

Down with Brackets(900)


Square Year(800)

https://codeforces.com/problemset/problem/2114/A

#include <iostream>
#include <cmath>
using namespace std;
void solve()
{int n;cin >> n;int k = sqrt(n);if (k * k != n){cout << -1 << endl;return;}cout << 0 << " " << k << endl;
}
int main()
{int t;cin >> t;while (t--){solve();}return 0;
}

 Not Quite a Palindromic String(900)

https://codeforces.com/problemset/problem/2114/B

#include <iostream>
#include <algorithm>
using namespace std;
void solve()
{int n, k;cin >> n >> k;int zero = 0;int one = 0;char t;for (int i = 0; i < n; i++){cin >> t;if (t == '0'){zero++;}else if (t == '1'){one++;}}int l = max(one, zero) - n / 2;int r = zero / 2 + one / 2;if (k >= l && k <= r){if (l % 2 == 1){if (k % 2 == 1){cout << "YES" << endl;return;}}else if (l % 2 == 0){if (k % 2 == 0){cout << "YES" << endl;return;}}}cout << "NO" << endl;return;
}
int main()
{int t;cin >> t;while (t--){solve();}return 0;
}

Down with Brackets(900)

https://codeforces.com/problemset/problem/2110/B

#include <iostream>
#include <string>
using namespace std;
void solve()
{string n;cin >> n;int res = 0;for (int i = 1; i < n.size() - 1; i++){if (n[i] == '('){res++;}else{res--;}if (res < 0){cout << "YES" << endl;return;}}if (res == 0){cout << "NO" << endl;return;}else{cout << "NO" << endl;return;}
}
int main()
{int t;cin >> t;while (t--){solve();}return 0;
}

http://www.xdnf.cn/news/10131.html

相关文章:

  • centos7.6阿里云镜像各个版本介绍
  • 【软件安装那些事 3 】CAD(2026 V60.7z) 安装教程(中文简体版)步骤完整不跳步 { 附软件提取下载链接,永久有效---------百度网盘 }
  • @Pushgateway配置与使用
  • 广东省林学会新办林业造林资质具体条件?
  • 1 Studying《Java编程思想》
  • 现代密码学 | 高级加密标准(AES)
  • Java枚举详解:从基础到高级应用
  • Keil MDK5.37或更高版本不再预装ARM Compiler Version5导致编译错误的解决方法
  • 2025最新版|八股文面试题库+答案详解(附高频考点解析)
  • Python 训练营打卡 Day 30-模块和库的导入
  • VirtualBox给Rock Linux9.x配置网络
  • Python-118:有限制的楼梯攀登
  • 如何把TikTok的视频下载到本地?
  • 企业应用AI对向量数据库选型思考
  • 华院计算出席信创论坛,分享AI教育创新实践并与燧原科技共同推出教育一体机
  • Ubuntu系统下可执行文件在桌面单击运行教程
  • type system_app, domain, coredomain; 和 typeattribute system_app coredomain; 区别
  • 《操作系统真相还原》——加载器
  • pikachu通关教程-RCE
  • ACS期刊的投稿查重要求
  • PHP 垃圾回收高级特性
  • 2025年大一ACM训练-尺取
  • 头歌之动手学人工智能-Pytorch 之线性回归
  • MySQL数据表添加字段(三种方式)
  • 【C++并发编程01】初识C++并发编程
  • @Prometheus 监控操作系统-Exporter(Win Linux)
  • mysql数据库基础命令总结常用10个
  • 需求可测试性评价
  • selenium自动化浏览器
  • c++流之sstream/堆or优先队列的应用[1]