好久没见过CF有这么水的contest了,蒟蒻赶紧找找自信

A. Subtract or Divide

#include<iostream>

using namespace std;

int main(){
int T,n;
cin>>T;
while(T--)
{
cin>>n;
if(n<=3) n--;
else n=2+(n&1);
cout<<n<<endl;
}
return 0;
}

B. Non-Substring Subsequence

#include<iostream>
#include<cstring> using namespace std; int main(){
int T;
cin>>T;
while(T--)
{
int n,q;
string s;
cin>>n>>q>>s;
while(q--)
{
int l,r;
bool good=false;
cin>>l>>r;
l--;
r--;
for(int i=0;i<l && good==false; i++)
if(s[i]==s[l]) good=true;
for(int i=r+1;i<n && good==false;i++)
if(s[i]==s[r]) good=true;
if(good==true) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
return 0;
}

C. String Equality

这里有必要记录两个很有意思的小知识点,都是C11标准里面新增的,array数组和auto类型变量,auto类型可以根据你赋值的数据自动分配数据类型,用起来十分方便

array<T,N> 模板定义了一种相当于标准数组的容器类型。它是一个有 N 个 T 类型元素的固定序列。除了需要指定元素的类型和个数之外,它和常规数组没有太大的差别。显然,不能增加或删除元素。

模板实例的元素被内部存储在标准数组中。和标准数组相比,array 容器的额外幵销很小,但提供了两个优点:如果使用 at(),当用一个非法的索引访问数组元素时,能够被检测到,因为容器知道它有多少个元素,这也就意味着数组容器可以作为参数传给函数,而不再需要单独去指定数组元素的个数。

使用 array 容器类型时,需要在源文件中包含头文件 array。

#include<iostream>
#include<cstring>
#include<algorithm>
#include<array> using namespace std; int main(){
int T;
cin>>T;
while(T--)
{
int n,k;
string s1,s2;
array<int, 27> have{}, need{};
cin>>n>>k>>s1>>s2;
for(auto& c: s1)
have[c-'a']++;
for(auto& c: s2)
need[c-'a']++;
bool good = true;
for(int i=0;i<26;i++)
{
if(have[i]<need[i] || (have[i] -= need[i]) % k)
good=false;
have[i+1]+=have[i];
}
if(good) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}

D.Circle Game

逻辑题

#include <bits/stdc++.h>
using namespace std; int main()
{
int T;
cin >> T;
while(T--) {
int n, k;
cin >> n >> k;
int x = 0, y = 0;
for(;;)
{
if(x <= y && pow(x+k, 2) + pow(y, 2) <= pow(n, 2))
x += k;
else if(x > y && pow(y+k, 2) + pow(x, 2) <= pow(n,2))
y += k;
else break;
}
if(x == y)
cout << "Utkarsh" << endl;
else
cout << "Ashish" << endl;
}
return 0;
}

ACM-CodeForces-#685(Div.2)的更多相关文章

  1. Codeforces #344 Div.2

    Codeforces #344 Div.2 Interview 题目描述:求两个序列的子序列或操作的和的最大值 solution 签到题 时间复杂度:\(O(n^2)\) Print Check 题目 ...

  2. Codeforces #345 Div.1

    Codeforces #345 Div.1 打CF有助于提高做题的正确率. Watchmen 题目描述:求欧拉距离等于曼哈顿距离的点对个数. solution 签到题,其实就是求有多少对点在同一行或同 ...

  3. Codeforces Beta Round #27 (Codeforces format, Div. 2)

    Codeforces Beta Round #27 (Codeforces format, Div. 2) http://codeforces.com/contest/27 A #include< ...

  4. Codeforces#441 Div.2 四小题

    Codeforces#441 Div.2 四小题 链接 A. Trip For Meal 小熊维尼喜欢吃蜂蜜.他每天要在朋友家享用N次蜂蜜 , 朋友A到B家的距离是 a ,A到C家的距离是b ,B到C ...

  5. codeforces #592(Div.2)

    codeforces #592(Div.2) A Pens and Pencils Tomorrow is a difficult day for Polycarp: he has to attend ...

  6. codeforces #578(Div.2)

    codeforces #578(Div.2) A. Hotelier Amugae has a hotel consisting of 1010 rooms. The rooms are number ...

  7. codeforces #577(Div.2)

    codeforces #577(Div.2) A  Important Exam A class of students wrote a multiple-choice test. There are ...

  8. codeforces #332 div 2 D. Spongebob and Squares

    http://codeforces.com/contest/599/problem/D 题意:给出总的方格数x,问有多少种不同尺寸的矩形满足题意,输出方案数和长宽(3,5和5,3算两种) 思路:比赛的 ...

  9. [ACM]Codeforces Round #534 (Div. 2)

    A. Splitting into digits Vasya has his favourite number n. He wants to split it to some non-zero dig ...

  10. Codeforces Round #685 (Div. 2)

    待补 A #include <bits/stdc++.h> using namespace std; int n; int main() { int __; scanf("%d& ...

随机推荐

  1. Ubuntu系统运行Steam中VR游戏的相关软件环境配置说明

    ubuntu下的SteamVR(HTCVive)设置教程 贴吧链接     https://tieba.baidu.com/p/5333529880 运行SteamVR出现的一些问题解决方案参考链接  ...

  2. 需要改动node_modules,并且别人也可以同步,插件 patch-package

    patch-package 转自:https://www.cnblogs.com/lovewhatIlove/p/15724812.html 1.简介:有个功能需要修改node_modules里面的代 ...

  3. python3GUI--用Tk开发一款恶搞蓝屏软件(附源码)

    目录 一.准备工作 1.Tkinter 2.科普-电脑蓝屏 二.预览 1.蓝屏-win10.win11(中文版) 2.蓝屏-win10.win11(英文版) 3.Windows其他版本(XP.Win7 ...

  4. upload 上传文件

    func SaveUploadedFile(file *multipart.FileHeader, dst string) error{ src, err := file.Open() if err ...

  5. C语言初级阶段8——预处理

    C语言初级阶段8--预处理 预定义符号 1.概念:预处理是编译之前做的一些事. 2.常用的预定义符号: 注意:: (1)-(4)的格式占位符都用%是,如:printf("%s",D ...

  6. yum随笔

    1.一般企业的服务器都能联网,所以装包都是装系统给的或者是自己去第三方的源,如下: http://mirrors.aliyun.com/repo/Centos-7.repo http://mirror ...

  7. js指南

    1.for /in: 与for/of相比,可迭代对象不同,in后面可以是任意对象.数组.字符串.集合和映射可迭代. object.keys()   object.values()   object.e ...

  8. STM32使用DMA接收不定长数据

    开启串口,是能串口全局中断 配置DMA并勾选Memory选项 继续配置工程并且生成代码 添加一些串口通讯使用的全局变量 #define BUFFER_SIZE 128 uint8_t Tx_Buf[5 ...

  9. 转载C#加密方法

    方法一:    //须添加对System.Web的引用     using System.Web.Security;          ...          /// <summary> ...

  10. 事与愿违( backfire effect ) 的故事

    例如:我作为一个需求者,我想要买世界上最便宜的苹果手机,但是当我进入市场去寻找世界上最便宜苹果手机的时候,这一行为本身就使得苹果手机的价格上升. 作为供应者,我本来要去卖最贵的房子,但是当我作为开发商 ...