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

Codeforces Round 1030 (Div. 2)

Problem - A - Codeforces

构造题,构造下面的万能序列:
1(填0)(填1)0

来看代码:
 

#include <bits/stdc++.h>
using namespace std;int main()
{int t;cin>>t;while(t--){int n,k;cin>>n>>k;vector<int>arr(n);if(k==0){for(int i = 0;i<n;i++){cout<<0;}cout<<"\n";continue;}if(k==1){cout<<1;for(int i = 1;i<n;i++){cout<<0;}cout<<"\n";continue;}if(k==n){for(int i = 0;i<n;i++){cout<<1;}cout<<"\n";continue;}//正式开始arr[0] = 1;for(int i = 1;i<k;i++){arr[n-i-1] = 1;}for(int i = 0;i<n;i++){cout<<arr[i];}cout<<"\n";} 
}

Problem - B - Codeforces

解决方法:

来看代码:

#include <bits/stdc++.h>
using namespace std;int main()
{int t;cin>>t;while(t--){int n;cin>>n;cout<<2*n-1<<"\n";cout<<1<<" "<<1<<" "<<n<<"\n";for(int i = 2;i<=n;i++){cout<<i<<" "<<1<<" "<<i-1<<"\n";cout<<i<<" "<<i<<" "<<n<<"\n";} } 
}

相关文章:

  • STM32项目---汽车氛围灯
  • Flutter JSON解析全攻略:使用json_serializable实现高效序列化
  • MySQL 调优笔记
  • 项目拓展-简易SQL监控,P6SPY拦截所有jdbc连接并打印执行SQL
  • 第1章 C# 和 .NET 框架 笔记
  • 【知识图谱构建系列3】zero-shot的理念介绍
  • Android xml的Preference设置visibility=“gone“ 无效分析解决
  • 【无标题】【2025年软考中级】第三章数据结构3.2 栈与队列
  • LeetCode - 69. x 的平方根
  • 数据结构 学习 链表 2025年6月14日08点01分
  • 力扣Hot100每日N题(15~16)
  • sqli-labs靶场46-53关(综合)
  • 拆解 CMS/G1/ZGC 三种垃圾回收器算法过程
  • Python实战应用-Python操作MySQL数据库
  • leetcode2-两数相加
  • 【CF】Day84——Codeforces Round 862 (Div. 2) D (⭐树的直径的性质 + DFS找树的直径)
  • K8S中使用英伟达GPU
  • 在 CentOS中安装Docker并安装青龙脚本——笔记
  • Vue3 实现老虎机抽奖游戏
  • Spring AI Alibaba Graph 实践
  • 可以做免费广告的网站有哪些/网站收录查询系统
  • 网站系统建设思想如何写/网站开发建站
  • 做推广哪个网站最好/百度网首页官网登录
  • 网站彩票做号/站长工具seo综合查询降级
  • 提供网站建设报价/百色seo外包
  • 在线制作logo图标免费生成/seo站长工具查询