#366 A-C
A. Hulk
题意是给你一个n 输出一个英文字符串,找下规律就发现
当(i!=n&&i%2==1) 输出的是 I hate that (注意大写)
当(i!=n&&i%2==0) 输出的是 I love that (注意大写)
当(i==n&&i%2==1) 输出的是 I love it (注意大写)
当(i==n&&i%2==0) 输出的是 I love it (注意大写)
注意有空格;
#include<bits/stdc++.h>
#define int long long
#define MAX(a,b,c) max(a,max(b,c))
#define MIN(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned long long uLL;
using namespace std;
const int maxn=1e5+;
const int INF=0x3f3f3f3f;
int32_t main()
{
int n; cin>>n;
for(int i=;i<n;i++)
{
if(i%==) cout<<"I hate that"<<" ";
else cout<<"I love that"<<" ";
}
if(n%==) cout<<"I hate it"<<endl;
else cout<<"I love it"<<endl;
}
A.cpp
B. Spider Man
题意有点难,每次给你以一个数n 让你去操作 输出结果;
每次操作是找一个圈 长度为x>=2 分成1-p p-两段
每个n 要去到 n-1 个点
n为偶数时 首次可以去掉 0 2 个点 第一个操作者可以操作最后一下,第一个操作者win
当n为奇数时候 首次每次只能去掉1个点 就变成了奇数+偶数 第一个操作者 lost
#include<bits/stdc++.h>
#define int long long
#define MAX(a,b,c) max(a,max(b,c))
#define MIN(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned long long uLL;
using namespace std;
const int maxn=1e5+;
const int INF=0x3f3f3f3f;
int32_t main()
{
int n; cin>>n; int t=;
for(int i=;i<=n;i++)
{
int x; cin>>x;
if(x%==) cout<<t<<endl;
else
{
if(t==) t=;
else t=;
cout<<t<<endl;
}
}
}
B.cpp
C. Thor
题目意思就是n个程序发送手机通知 ,你去查看通知,问你每次剩下多少通知没看
有3种类型
type 1 应用 b 发送一个通知;
type 2 阅读 b 的所有通知;
type 3 阅读前t个通知(可以重复阅读)
直接暴力肯定过不了 n*p 复杂度过不去
我们注意 单独的type2 type3 都可以用o(n)的复杂度过去
我们就要把这两个联系在一起
执行type2操作时 我们要去重(type3操过的 (一前type2操作))
单独的type2时 每次type2时 总数减去 新加的amout[b] ;
新加的mount[b] 中可能有type3操作过的; 我们要在type中减去;
执行type3操作时候 遍历上一次 t1到这次的;
中间有type2读过的 所以要type2要标记位置,使type3遍历时候跳过这个数
#include<bits/stdc++.h>
#define int long long
#define MAX(a,b,c) max(a,max(b,c))
#define MIN(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned long long uLL;
using namespace std;
const int maxn=3e5+;
const int INF=0x3f3f3f3f;
vector<int> vs[maxn];
pair<int,int> pa[maxn];
int amout[maxn];
int pos[maxn];
int32_t main()
{
int n,q; cin>>n>>q;
int cnt=,sum=;
int p=;
for(int i=;i<q;i++)
{
int a,b; cin>>a>>b;
if(a==)
{
vs[b].pb(cnt);
amout[b]++;
sum++;
pa[cnt].first=;
pa[cnt].second=b;
cnt++;
}
if(a==)
{
sum=sum-amout[b];
amout[b]=;
for(int j=pos[b];j<vs[b].size();j++)
{
pa[vs[b][j]].first=;
}
pos[b]=vs[b].size();
}
if(a==)
{
for(int j=p;j<b;j++)
{
if(!pa[j].first)
{
pa[j].first=;
sum--;
amout[pa[j].second]--;
}
}
p=max(p,b);
}
cout<<sum<<endl;
} }
C.cpp
#366 A-C的更多相关文章
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- <Tree> 298 250 366 199(高频) 98(高频)
298. Binary Tree Longest Consecutive Sequence 先序遍历,根左右.如果该节点的 value == 父节点value + 1, 则长度+1; 否则重置为1. ...
- Codeforces Round #366 (Div. 2)
CF 复仇者联盟场... 水题 A - Hulk(绿巨人) 输出love hate... #include <bits/stdc++.h> typedef long long ll; co ...
- 366. Find Leaves of Binary Tree
Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves ...
- LintCode 366 Fibonacci
/* 1st method will lead to time limit *//* the time complexity is exponential sicne T(n) = T(n-1) + ...
- Codeforces Round #366 Div.2[11110]
这次出的题貌似有点难啊,Div.1的Standing是这样的,可以看到这位全站排名前10的W4大神也只过了AB两道题. A:http://codeforces.com/contest/705/prob ...
- Codeforces Round #366 (Div. 2) B
Description Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a ...
- Codeforces Round #366 (Div. 2) C 模拟queue
C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...
- Codeforces Round #366 (Div. 2) B 猜
B. Spider Man time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces Round #366 (Div. 2) A
A. Hulk time limit per test 1 second memory limit per test 256 megabytes input standard input output ...
随机推荐
- Win10系列:JavaScript 项目模板中的文件和项模板文件
通过上面内容的学习,相信读者已经对各种项目模板和项模板有了大致的了解,本节将进一步介绍项目模板中默认包含的项目文件以及项模板文件,首先讲解这些文件中的初始内容以及作用,然后介绍在一个页面中如何添加控件 ...
- 银联支付 Asp.Net 对接开发内容简介
银联对接开发主要包含测试环境以及生产环境两部分. 其中程序开发部分测试以及生产是相同的. 不同的是,测试环境与生产环境请求支付的Url地址,以及分别使用的证书不同. 一.配置部分 1,测试环境证书获取 ...
- while循环以及格式化输出总结
while循环: while 无限循环 count = 1 sum = 0 while True: sum = sum + count count = count + 1 if count == 10 ...
- [HDU2475]Box
Problem 先告诉你每个盒子在哪个盒子的内部 接下来有M个操作: 可以把一个盒子及里面的盒子移到另外一个盒子的内部 或者询问你某个盒子最外面的盒子是哪个 Solution 首先可以建成一个图,然后 ...
- Java判断对象是否为NULL
Java使用反射判断对象是否为NULL 判断Java对象是否为null可以有两层含义: 第一层: 直接使用 object == null 去判断,对象为null的时候返回true,不为null的时候 ...
- git-github-TortoiseGit综合使用教程(二)快速入门
:建立版本库 在github网站上创建一个版本库,并复制clone地址. git@github.com:jackadam1981/Flask_Base.git https://github.com/j ...
- SpringBoot 上传、下载(四)
工程目录结构 完整代码: 1.pom.xml 首先当然是添加依赖,用到thymeleaf模板渲染html页面 <project xmlns="http://maven.apache.o ...
- flask小例
#写一个app.py,处理3个URL: ''' GET / : 首页,返回Home; GET /signin:登录页,显示登录表单; POST /signin: 处理登录表单,显示登录结果. ''' ...
- jq demo—图片翻页展示效果 animate()动画
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- python笔记4-if..elif-else条件语句
python中条件判断使用if else来判断,多分支的话使用if elif ... else,也就是如果怎么怎么样就怎么怎么样,否则就怎么怎么这样,格式如下: #if是布尔类型判断,1个是真1个是假 ...