ACM-CodeForces-#685(Div.2)
好久没见过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)的更多相关文章
- Codeforces #344 Div.2
Codeforces #344 Div.2 Interview 题目描述:求两个序列的子序列或操作的和的最大值 solution 签到题 时间复杂度:\(O(n^2)\) Print Check 题目 ...
- Codeforces #345 Div.1
Codeforces #345 Div.1 打CF有助于提高做题的正确率. Watchmen 题目描述:求欧拉距离等于曼哈顿距离的点对个数. solution 签到题,其实就是求有多少对点在同一行或同 ...
- Codeforces Beta Round #27 (Codeforces format, Div. 2)
Codeforces Beta Round #27 (Codeforces format, Div. 2) http://codeforces.com/contest/27 A #include< ...
- Codeforces#441 Div.2 四小题
Codeforces#441 Div.2 四小题 链接 A. Trip For Meal 小熊维尼喜欢吃蜂蜜.他每天要在朋友家享用N次蜂蜜 , 朋友A到B家的距离是 a ,A到C家的距离是b ,B到C ...
- codeforces #592(Div.2)
codeforces #592(Div.2) A Pens and Pencils Tomorrow is a difficult day for Polycarp: he has to attend ...
- codeforces #578(Div.2)
codeforces #578(Div.2) A. Hotelier Amugae has a hotel consisting of 1010 rooms. The rooms are number ...
- codeforces #577(Div.2)
codeforces #577(Div.2) A Important Exam A class of students wrote a multiple-choice test. There are ...
- codeforces #332 div 2 D. Spongebob and Squares
http://codeforces.com/contest/599/problem/D 题意:给出总的方格数x,问有多少种不同尺寸的矩形满足题意,输出方案数和长宽(3,5和5,3算两种) 思路:比赛的 ...
- [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 ...
- Codeforces Round #685 (Div. 2)
待补 A #include <bits/stdc++.h> using namespace std; int n; int main() { int __; scanf("%d& ...
随机推荐
- 移动端H5开发坑位指南
一.HTML方向 调用系统功能 使用<a>能快速调用移动设备的电话/短信/邮件三大通讯功能,使用<input>能快速调用移动设备的的图库/文件. 这些功能方便了页面与系统的交互 ...
- SpringBoot(概述、起步依赖原理分析、SpringBoot配置(配置文件分类、YAML))
SpringBoot概述 Spring Boot 是由 Pivotal 团队提供用来简化 Spring 的搭建和开发过程的全新框架.随着近些年来微服务技术的流行,Spring Boot 也成了时下炙手 ...
- mysql 参数配置
https://www.jb51.net/article/48082.htm https://www.cnblogs.com/angryprogrammer/p/6667741.html
- js使用sort将JSON数据进行排序
在把数据通过Echarts展示成统计图模式时,柱状统计图需要将数据进行从大到小来排序! 下面为所需要的数据: 1 { 2 mapData: [ 3 {name: '北京',value: '555'}, ...
- [fiddler的使用]添加常用字段(请求耗时,客户端请求时间,IP地址)
1. /* 显示请求耗时 */ function BeginRequestTime(oS: Session) { if (oS.Timers != null) { return oS.Timers.C ...
- echarts属性大全
// 全图默认背景 // backgroundColor: 'rgba(0,0,0,0)', // 默认色板 color: ['#ff7f50','#87cefa','#da70d6','#32cd ...
- Hbase操作与编程使用
1.任务: 列出HBase所有的表的相关信息,例如表名: 3. 编程完成以下指定功能(教材P92下): (1)createTable(String tableName, String[] fields ...
- STL二分查找算法
二分法检索又称折半检索,二分法检索的基本思想是设字典中的元素从小到大有序地存放在数组(array)中,首先将给定值key与字典中间位置上元素的关键码(key)比较,如果相等,则检索成功:否则,若key ...
- OSIDP-并发:死锁和饥饿-06
死锁原理 死锁:一组相互竞争系统资源或者进行通信的进程间"永久"阻塞的现象. 资源分为两类:可重用资源和可消耗资源. 可重用资源:一次只能被一个进程使用且不会被耗尽的资源.如处理器 ...
- 02题解-洛谷 P2395 BBCode转换Markdown 题解
洛谷 P2395 BBCode转换Markdown 题解 题目传送门: here. 一道毒瘤的大模拟,给了你一部分的 BBCode 和 Markdown 语法,叫你转换.如下表: BBCode Mar ...