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 ...
随机推荐
- Gridview的stretchMode等属性详解
<GridView android:id="@+id/grid"android:layout_width="fill_parent"android:lay ...
- C语言基础五 数组的应用
.根据用户输入的10人成绩并将其保存到数组中,求最高成绩,最低成绩和平均成绩 int scoure[10];//存储10个数据的数组 int i; int sum;//总成绩 int max,min, ...
- Java的七大排序
一.各个算法的时间复杂度 二,具体实现 1.直接选择排序 基本思想:在长度为n的序列中,第一次遍历找到该序列的最小值,替换掉第一个元素,接着从第二个元素开始遍历,找到剩余序列中的最小值,替换掉第二个元 ...
- Linux文件结构-底层文件访问&文件目录和维护
每个运行中的程序被称为进程(process),它有一些与之关联的文件描述符(一些小值整数).可以通过文件描述符访问打开的文件或设备. 一个程序运行时,一般会有三个文件描述符与之对应 0:标准输入 1: ...
- 关于广州xx公司对驰骋BPM, 流程引擎表单引擎 常见问题解答
关于广州xx公司对驰骋BPM, 流程引擎表单引擎 常见问题解答 @驰骋工作流,ccflow周朋 周总早, ccflow 功能很强大,在体验过程中,以下几个问题需沟通下: 先使用.net 再使用java ...
- 0x01 C语言-编写第一个hello world
学习每一个编程语言都是从 "Hello world!" 开始的,这好像就是编程界一条不成文的规定一样. 在这篇文章中,我将教大家编写一个可以输出 "Hello world ...
- MFC/QT 学习笔记(四)——MFC基于对话框学习控件(上)
新建项目->MFC模板->MFC应用程序->应用程序类型:基于对话框->...OK 解决方案资源管理器->资源文件->xxx.rc->进入:资源视图-> ...
- 内网学习之MySQL服务提权
利用MySQL提权原理: 1.具有mysql的root权限,且mysql以system权限运行. 2.具有执行sql语句的权限,webshell或者外连皆可 UDF提权 UDF(user define ...
- Android实战项目——家庭记账本(七)
今天主要实现了登录注册功能的客户端和服务端,但由于短信接口调用出现问题,导致注册功能还不完整. 截止到今天,APP的功能已经基本完成,后续还会陆陆续续的完善各功能模块与服务端的交互,因为需要和云端关联 ...
- 【python基础语法】函数的作用域和内置函数和关键字(第7天课堂笔记)
一.函数的作用域: 1.全局变量 2.局部变量 3.global 二.内置函数 1.常见的内置函数 print : 输出 input : 输入 type : 查看数据类型 id : 获取数据的内存地址 ...