AtCoder Beginner Contest 068 ABCD题
A - ABCxxx
Time limit : 2sec / Memory limit : 256MB
Score : 100 points
Problem Statement
This contest, AtCoder Beginner Contest, is abbreviated as ABC.
When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC.
What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
Constraints
- 100≤N≤999
Input
Input is given from Standard Input in the following format:
N
Output
Print the abbreviation for the N-th round of ABC.
Sample Input 1
100
Sample Output 1
ABC100
The 100th round of ABC is ABC100.
Sample Input 2
425
Sample Output 2
ABC425
Sample Input 3
999
Sample Output 3
ABC999
题解:水水
#include <cstdio>
int main()
{
int n;
scanf("%d",&n);
printf("ABC%d\n",n);
return ;
}
B - Break Number
Time limit : 2sec / Memory limit : 256MB
Score : 200 points
Problem Statement
Takahashi loves numbers divisible by 2.
You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.
Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.
For example,
- 6 can be divided by 2 once: 6 -> 3.
- 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.
- 3 can be divided by 2 zero times.
Constraints
- 1≤N≤100
Input
Input is given from Standard Input in the following format:
N
Output
Print the answer.
Sample Input 1
7
Sample Output 1
4
4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.
Sample Input 2
32
Sample Output 2
32
Sample Input 3
1
Sample Output 3
1
Sample Input 4
100
Sample Output 4
64 题解:水水
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
if(n<) cout<<<<endl;
else if(n<) cout<<<<endl;
else if(n<) cout<<<<endl;
else if(n<) cout<<<<endl;
else if(n<) cout<<<<endl;
else if(n<) cout<<<<endl;
else cout<<<<endl;
return ;
}
C - Cat Snuke and a Voyage
Time limit : 2sec / Memory limit : 256MB
Score : 300 points
Problem Statement
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N.
There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island ai and Island bi.
Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.
Help him.
Constraints
- 3≤N≤200 000
- 1≤M≤200 000
- 1≤ai<bi≤N
- (ai,bi)≠(1,N)
- If i≠j, (ai,bi)≠(aj,bj).
Input
Input is given from Standard Input in the following format:
N M
a1 b1
a2 b2
:
aM bM
Output
If it is possible to go to Island N by using two boat services, print POSSIBLE
; otherwise, print IMPOSSIBLE
.
Sample Input 1
3 2
1 2
2 3
Sample Output 1
POSSIBLE
Sample Input 2
4 3
1 2
2 3
3 4
Sample Output 2
IMPOSSIBLE
You have to use three boat services to get to Island 4.
Sample Input 3
100000 1
1 99999
Sample Output 3
IMPOSSIBLE
Sample Input 4
5 5
1 3
4 5
2 3
2 4
1 4
Sample Output 4
POSSIBLE
You can get to Island 5 by using two boat services: Island 1 -> Island 4 -> Island 5.
题目大意:给出一个有向图,问1->n能否两步到达
解题思路:dfs搜索,或者判断1的下一个结点和n的上一个结点是否有公共的就行了
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL INF=1e18;
const int MAXN=2e5+;
const double eps=1e-;
bool vis[MAXN];
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF){
int u,v;
bool flag=false;
for(int i=;i<=n;i++)
vis[i]=false;
for(int i=;i<=m;i++){
scanf("%d%d",&u,&v);
if(flag) continue;
if(u==){
if(vis[v]){
flag=true;
}
vis[v]=true;
}else if(v==n){
if(vis[u]){
flag=true;
}
vis[u]=true;
}
}
if(flag) printf("POSSIBLE\n");
else printf("IMPOSSIBLE\n");
}
return ;
}
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL INF=1e18;
const int MAXN=2e5+;
const double eps=1e-;
int tot;
int head[MAXN];
int n,m;
struct Edge
{
int from,to,nxt;
}e[MAXN];
void addedge(int u,int v)
{
e[tot].from=u;
e[tot].to=v;
e[tot].nxt=head[u];
head[u]=tot++;
}
bool dfs(int s,int t,int k)
{
if(s==n&&k==) return true;
for(int i=head[s];i!=-;i=e[i].nxt){
int to=e[i].to;
if(dfs(to,n,k+)) return true;
}
return false;
}
int main()
{
int d,k;
while(scanf("%d%d",&n,&m)!=EOF){
memset(head,-,sizeof(head));
int u,v;
for(int i=;i<=m;i++){
scanf("%d%d",&u,&v);
addedge(u,v);
}
if(dfs(,n,))
printf("POSSIBLE\n");
else printf("IMPOSSIBLE\n");
}
return ;
}
D - Decrease (Contestant ver.)
Time limit : 2sec / Memory limit : 256MB
Score : 600 points
Problem Statement
We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N−1 or smaller.
- Determine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element by N, and increase each of the other elements by 1.
It can be proved that the largest element in the sequence becomes N−1 or smaller after a finite number of operations.
You are given an integer K. Find an integer sequence ai such that the number of times we will perform the above operation is exactly K. It can be shown that there is always such a sequence under the constraints on input and output in this problem.
Constraints
- 0≤K≤50×1016
Input
Input is given from Standard Input in the following format:
K
Output
Print a solution in the following format:
N
a1 a2 ... aN
Here, 2≤N≤50 and 0≤ai≤1016+1000 must hold.
Sample Input 1
0
Sample Output 1
4
3 3 3 3
Sample Input 2
1
Sample Output 2
3
1 0 3
Sample Input 3
2
Sample Output 3
2
2 2
The operation will be performed twice: [2, 2] -> [0, 3] -> [1, 1].
Sample Input 4
3
Sample Output 4
7
27 0 0 0 0 0 0
Sample Input 5
1234567894848
Sample Output 5
10
1000 193 256 777 0 1 1192 1234567891011 48 425 题解:(构造)从n个t变化到n个t-1,恰好要n步,并且其中每一步的max值都>=t,所以把50个49当成最终局面,从这里开始,根据输入的K计算初始局面即可
此题题解转自:http://www.cnblogs.com/autsky-jadek/
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
ll K;
int main(){
cin>>K;
int n=;
printf("%d\n",n);
ll a=K/(ll)n; ll b=K%(ll)n;
int cnt=;
for(int i=;i<=(int)b;++i){
++cnt;
cout<<49ll+a+((ll)n-(b-1ll))<<(cnt==n ? '\n' : ' ');
}
for(int i=;i<=n-(int)b;++i){
++cnt;
cout<<49ll+a-b<<(cnt==n ? '\n' : ' ');
}
return ;
}
AtCoder Beginner Contest 068 ABCD题的更多相关文章
- AtCoder Beginner Contest 053 ABCD题
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...
- AtCoder Beginner Contest 069 ABCD题
题目链接:http://abc069.contest.atcoder.jp/assignments A - K-City Time limit : 2sec / Memory limit : 256M ...
- AtCoder Beginner Contest 070 ABCD题
题目链接:http://abc070.contest.atcoder.jp/assignments A - Palindromic Number Time limit : 2sec / Memory ...
- AtCoder Beginner Contest 057 ABCD题
A - Remaining Time Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Dol ...
- AtCoder Beginner Contest 051 ABCD题
A - Haiku Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement As a New Yea ...
- AtCoder Beginner Contest 052 ABCD题
A - Two Rectangles Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement The ...
- AtCoder Beginner Contest 054 ABCD题
A - One Card Poker Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Ali ...
- AtCoder Beginner Contest 058 ABCD题
A - ι⊥l Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Three poles st ...
- AtCoder Beginner Contest 050 ABC题
A - Addition and Subtraction Easy Time limit : 2sec / Memory limit : 256MB Score : 100 points Proble ...
随机推荐
- 解决egg-mysql连接数据库报错问题
遇到这个问题,我在网上找了好多资料,最终于解决了!!!★,°:.☆( ̄▽ ̄)/$:.°★ . 我遇到的问题是这样的:链接mysql完全按照官网上做的,但是在yarn dev 时就是一直报错,错误我就不 ...
- 展讯sprd_battery.c 充电驱动
sprd_battery.c 是充电驱动,这个是充电功能的核心内容,电量显示策略.温度检测策略.充电保护机制等功能在这里实现,功能实现与硬件细节剥离,调用通用接口实现逻辑控制: 1 sprdbat_p ...
- 简易音乐播放器主界面设计 - .NET CORE(C#) WPF开发
微信公众号:Dotnet9,网站:Dotnet9,问题或建议:请网站留言, 如果对您有所帮助:欢迎赞赏. 简易音乐播放器主界面设计 - .NET CORE(C#) WPF开发 阅读导航 本文背景 代码 ...
- spring cloud微服务快速教程之(八) Spring Cloud Alibaba--nacos(二)、配置中心
0-前言 上一篇我们介绍了nacos作为服务注册发现组件的功能,nacos还具有配置中心的功能,而且支持热加载: 在此之前,配置中心有Spring Cloud Config,实际上,用这个有很多风险和 ...
- Linux中“没有可用的软件包XX,但是它被其他软件包引用”的解决方法
踩坑经历 今天刚在虚拟机上安装好了ubuntu系统,在执行sudo apt install net-tools 命令时报错"没有可用的软件包net-tools,但是它被其他软件包引用&quo ...
- Mac上的屏幕截图不起作用该如何修复?
屏幕截图是Mac提供的内置功能,很少有它不起作用.但是由于某些意外的设置或硬件问题,Mac上的屏幕截图有时无法正常工作,这里提供的是Mac上的屏幕截图不起作用该如何修复? 1.在Mac上启用屏幕快照快 ...
- Go 使用小记
1.不能使用在运行时计算的值实例化这样的数组. 而是使用make初始化具有所需长度的切片. db := ConnMysql() rows, err := db.Query("select r ...
- C# 工具类LogHelper
一.创建一个WinForm的项目,并通过NuGet安装log4net. 二.创建LogHelper类以及log4net.config配置文件. 三.编写相关代码. 1.LogHelper类 using ...
- (int)、int.Parse()、int.TryParse()、Convert.ToInt32()区别
请看代码: //1.null. //int i1 = (int)null;//编译时报错:无法将“null”转换为“int”,因为后者是不可以为“null”的值类型. //int i2 = int.P ...
- C语言->关于文件数据的录入和输出调用的函数总结
数据输入输出对象之间的关系图: 函数使用说明: 1.一个字符的输入\输出,对象是键盘(缓存和屏幕) 1.1.getchar(a),putchar(a); 1.2.scanf(“%d”,&i), ...