Atcoder Panasonic Programming Contest 2020
前三题随便写,D题是一道dfs的水题,但当时没有找到规律,直接卡到结束
A - Kth Term /
Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 100100 points
Problem Statement
Print the KK-th element of the following sequence of length 3232:
1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
Constraints
- 1≤K≤321≤K≤32
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
KK
Output
Print the KK-th element.
Sample Input 1 Copy
6
Sample Output 1 Copy
2
The 66-th element is 22.
Sample Input 2 Copy
27
Sample Output 2 Copy
5
The 2727-th element is 55.
随便写
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N=1e6+10;
using namespace std;
typedef pair<int,int>PII;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;
int main(){
ios::sync_with_stdio(false);
cin>>n;
cout<<a[n-1]<<endl;
return 0;
}
B - Bishop /
Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 200200 points
Problem Statement
We have a board with HH horizontal rows and WW vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements?
Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r1r1-th row (from the top) and the c1c1-th column (from the left) to the square at the r2r2-th row and the c2c2-th column if and only if exactly one of the following holds:
- r1+c1=r2+c2r1+c1=r2+c2
- r1−c1=r2−c2r1−c1=r2−c2
For example, in the following figure, the bishop can move to any of the red squares in one move:
Constraints
- 1≤H,W≤1091≤H,W≤109
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
H WH W
Output
Print the number of squares the bishop can reach.
Sample Input 1 Copy
4 5
Sample Output 1 Copy
10
The bishop can reach the cyan squares in the following figure:
Sample Input 2 Copy
7 3
Sample Output 2 Copy
11
The bishop can reach the cyan squares in the following figure:
Sample Input 3 Copy
1000000000 1000000000
Sample Output 3 Copy
500000000000000000
如果行是偶数,那么涂色的方格数就是 行数/2*列数,如果是奇数, 行数/2(向上取整)*列数-列数/2,因为每一列的涂色方块相差1;
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N=1e6+10;
using namespace std;
typedef pair<int,int>PII; ll n,m,ans; int main(){
ios::sync_with_stdio(false);
cin>>n>>m;
if(n==1 || m==1) ans=1;
else if(n%2==0)
ans=((n+1)/2)*m;
else
ans=((n+1)/2)*m-m/2;
cout<<ans<<endl;
return 0;
}
C - Sqrt Inequality /
Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 300300 points
Problem Statement
Does √a+√b<√ca+b<c hold?
Constraints
- 1≤a,b,c≤1091≤a,b,c≤109
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
a b ca b c
Output
If √a+√b<√ca+b<c, print Yes
; otherwise, print No
.
Sample Input 1 Copy
2 3 9
Sample Output 1 Copy
No
√2+√3<√92+3<9 does not hold.
Sample Input 2 Copy
2 3 10
Sample Output 2 Copy
Yes
√2+√3<√102+3<10 holds.
没什么好说的,两边平方一下确保不会卡精度
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N=1e6+10;
using namespace std;
typedef pair<int,int>PII; long double a,b,c; int main(){
ios::sync_with_stdio(false);
cin>>a>>b>>c;
c=c-a-b;
if(c<=0) cout<<"No"<<endl;
else{
c=c*c/4;
if(a*b<c) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}
D - String Equivalence /
Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 400400 points
Problem Statement
In this problem, we only consider strings consisting of lowercase English letters.
Strings ss and tt are said to be isomorphic when the following conditions are satisfied:
- |s|=|t||s|=|t| holds.
- For every pair i,ji,j, one of the following holds:
- si=sjsi=sj and ti=tjti=tj.
- si≠sjsi≠sj and ti≠tjti≠tj.
For example, abcac
and zyxzx
are isomorphic, while abcac
and ppppp
are not.
A string ss is said to be in normal form when the following condition is satisfied:
- For every string tt that is isomorphic to ss, s≤ts≤t holds. Here ≤≤ denotes lexicographic comparison.
For example, abcac
is in normal form, but zyxzx
is not since it is isomorphic to abcac
, which is lexicographically smaller than zyxzx
.
You are given an integer NN. Print all strings of length NN that are in normal form, in lexicographically ascending order.
Constraints
- 1≤N≤101≤N≤10
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
NN
Output
Assume that there are KK strings of length NN that are in normal form: w1,…,wKw1,…,wK in lexicographical order. Output should be in the following format:
w1w1
::
wKwK
Sample Input 1 Copy
1
Sample Output 1 Copy
a
Sample Input 2 Copy
2
Sample Output 2 Copy
aa
ab
首先在纸上列一下,找出规律,直接dfs全排列,但是要注意第k位能取的字母数是前k-1字母的种类数+1;
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N=1e6+10;
using namespace std;
typedef pair<int,int>PII; int n;
int p=0,dif=0;
char s[N]; void dfs(int u){
if(u==n){
puts(s);
return;
} for(char i=0;i<=dif;++i){
s[p++]=i+'a';
int tmp=dif;
if(i==dif) dif++;
dfs(u+1);
p--;
dif=tmp;
} } int main(){
ios::sync_with_stdio(false);
cin>>n;
dfs(0);
return 0;
}
Atcoder Panasonic Programming Contest 2020的更多相关文章
- atcoder Keyence Programming Contest 2020 题解
比赛地址 A 题意:给一个\(n*m\)的初始为白色的矩阵,一次操作可以将一行或一列染成 黑色,问至少染出\(k\)个黑点的最少操作次数. \(n\),\(m\)<=100,\(k\)<= ...
- AtCoder AIsing Programming Contest 2020 D - Anything Goes to Zero (二进制,模拟)
题意:给你一个长度为\(n\)的\(01\)串,从高位到低位遍历,对该位取反,用得到的十进制数\(mod\)所有位上\(1\)的个数,不断循环直到为\(0\),输出每次遍历时循环的次数. 题解:根据题 ...
- M-SOLUTIONS Programming Contest 2020 题解
M-SOLUTIONS Programming Contest 2020 题解 目录 M-SOLUTIONS Programming Contest 2020 题解 A - Kyu in AtCode ...
- [AtCoder] NIKKEI Programming Contest 2019 (暂缺F)
[AtCoder] NIKKEI Programming Contest 2019 本来看见这一场的排名的画风比较正常就来补一下题,但是完全没有发现后两题的AC人数远少于我补的上一份AtCoder ...
- [AtCoder] Yahoo Programming Contest 2019
[AtCoder] Yahoo Programming Contest 2019 很遗憾错过了一场 AtCoder .听说这场是涨分场呢,于是特意来补一下题. A - Anti-Adjacency ...
- Panasonic Programming Contest (AtCoder Beginner Contest 186) E.Throne (数学,线性同余方程)
题意:有围着一圈的\(N\)把椅子,其中有一个是冠位,你在离冠位顺时针\(S\)把椅子的位置,你每次可以顺时针走\(K\)个椅子,问最少要走多少次才能登上冠位,或者走不到冠位. 题解:这题和洛谷那个青 ...
- AtCoder NIKKEI Programming Contest 2019 C. Different Strokes (贪心)
题目链接:https://nikkei2019-qual.contest.atcoder.jp/tasks/nikkei2019_qual_C 题意:给出 n 种食物,Takahashi 吃下获得 a ...
- AtCoder Dwango Programming Contest V E
题目链接:https://dwacon5th-prelims.contest.atcoder.jp/tasks/dwacon5th_prelims_e 题目描述: 给定一个大小为\(N\)的数组\(A ...
- HHKB Programming Contest 2020【ABCE】
比赛链接:https://atcoder.jp/contests/hhkb2020/tasks A - Keyboard 代码 #include <bits/stdc++.h> using ...
随机推荐
- 【Linux】在文件的指定位置插入数据
今天遇到一个似乎很棘手的问题,要在文件的中间,插入几条配置 这里就以my.cnf这个文件为例 1 [mysqld] 2 datadir=/var/lib/mysql 3 socket=/var/lib ...
- pandas 读写excel 操作(按索引和关键字读取行和列,写入csv文件)
pandas读写excel和csv操作总结 按索引读取某一列的值 按关键字读取某一列的值 按关键字查询某一行的值 保存成字典并写入新的csv import pandas as pd grades=pd ...
- Job for docker.service failed because start of the service was attempted too often. See "systemctl status docker.service" and "journalctl -xe" for details. To force a start use "systemctl reset-failed
安装docker时,自己添加了国内的hub.docker.com镜像 [root@ce-docker ~]# systemctl restart docker 出现以下报错:Job for docke ...
- oracle绑定变量测试及性能对比
1.创建测试数据 2.查看cursor_sharing的值 SQL> show parameter cursor_sharing; NAME TYPE VALUE --------------- ...
- luogu P4116 Qtree3
题目描述 给出N个点的一棵树(N-1条边),节点有白有黑,初始全为白 有两种操作: 0 i : 改变某点的颜色(原来是黑的变白,原来是白的变黑) 1 v : 询问1到v的路径上的第一个黑点,若无,输出 ...
- 【Azure Redis 缓存】Windows和Linux系统本地安装Redis, 加载dump.rdb中数据以及通过AOF日志文件追加数据
任务描述 本次集中介绍使用Windows和Linux()搭建本地Redis服务器的步骤,从备份的RDB文件中加载数据,以及如何生成AOF文件和通过AOF文件想已经运行的Redis追加数据. 操作步骤 ...
- ORB-SLAM2-tracking线程
tracking线程 Tracking线程的主要工作是从图像中提取ORB特征,根据上一帧进行姿态估计或者进行通过全局重定位初始化位姿,然后跟踪已经重建的局部地图,优化位姿,再根据一些规则确定新的关键帧 ...
- 提示框,对话框,路由跳转页面,跑马灯,幻灯片及list组件的应用
目录: 主页面的js业务逻辑层 主页面视图层 主页面css属性设置 跳转页面一的js业务逻辑层 跳转页面一的视图层 跳转页面二的视图层 跳转页面三的js业务逻辑层 跳转页面三的视图层 跳转页面三的cs ...
- C#高级编程第11版 - 第二章 索引
[1]2.1.1 Hello,World! 1. using static System.Console; // ... WriteLine("Hello World!"); 提前 ...
- vue-cli快速创建项目,可视化创建
之前学习了交互式创建,发现过程无聊,而且不方便,后面又学习了图形可视化创建,下面进行分享 1.打开cmd 2.输入vue ui,输入后会出现如下 C:\Users\12235>vue ui St ...