我好想有点思维江化,所以我想给这个丝毫没有问题的abc也写下

A - Palindromic Number


Time Limit: 2 sec / Memory Limit: 256 MB

Score : 100100 points

Problem Statement

You are given a three-digit positive integer NN.
Determine whether NN is a palindromic number.
Here, a palindromic number is an integer that reads the same backward as forward in decimal notation.

Constraints

  • 100≤N≤999100≤N≤999
  • NN is an integer.

Input

Input is given from Standard Input in the following format:

NN

Output

If NN is a palindromic number, print Yes; otherwise, print No.


Sample Input 1 Copy

Copy
575

Sample Output 1 Copy

Copy
Yes

N=575N=575 is also 575575 when read backward, so it is a palindromic number. You should print Yes.


Sample Input 2 Copy

Copy
123

Sample Output 2 Copy

Copy
No

N=123N=123 becomes 321321 when read backward, so it is not a palindromic number. You should print No.


Sample Input 3 Copy

Copy
812

Sample Output 3 Copy

Copy
No

Palindromic这个词必须熟啊,回文串的,直接搞,就是这点我感觉自己思想僵化,就是上次让判断时间是不是回文串一样的

我神特么写了个判断倒过来的数是不是一样的,石乐志,就是按照字符串读也比这个好啊

#include <bits/stdc++.h>
using namespace std;
int la(int n){
int s=;
while(n){
int t=n%;
s=s*+t;
n/=;
}
return s;
}
int main()
{
int n;
cin>>n;
printf("%s\n",n==la(n)?"Yes":"No");
return ;
}

其实只是判断百位和个位是否相同就好了

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
printf("%s\n",n/==n%?"Yes":"No");
return ;
}

B - Two Switches


Time Limit: 2 sec / Memory Limit: 256 MB

Score : 200200 points

Problem Statement

Alice and Bob are controlling a robot. They each have one switch that controls the robot.
Alice started holding down her button AA second after the start-up of the robot, and released her button BB second after the start-up.
Bob started holding down his button CC second after the start-up, and released his button DD second after the start-up.
For how many seconds both Alice and Bob were holding down their buttons?

Constraints

  • 0≤A<B≤1000≤A<B≤100
  • 0≤C<D≤1000≤C<D≤100
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

AA BB CC DD

Output

Print the length of the duration (in seconds) in which both Alice and Bob were holding down their buttons.


Sample Input 1 Copy

Copy
0 75 25 100

Sample Output 1 Copy

Copy
50

Alice started holding down her button 00 second after the start-up of the robot, and released her button 7575 second after the start-up.
Bob started holding down his button 2525 second after the start-up, and released his button 100100 second after the start-up.
Therefore, the time when both of them were holding down their buttons, is the 5050 seconds from 2525 seconds after the start-up to 7575 seconds after the start-up.


Sample Input 2 Copy

Copy
0 33 66 99

Sample Output 2 Copy

Copy
0

Alice and Bob were not holding their buttons at the same time, so the answer is zero seconds.


Sample Input 3 Copy

Copy
10 90 20 80

Sample Output 3 Copy

Copy
60

线段重合部分,直接水过

#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d,f;
cin>>a>>b>>c>>d;
f=min(d,b)-max(a,c);
if(f<)f=;
cout<<f<<endl;
return ;
}

C - Multiple Clocks


Time Limit: 2 sec / Memory Limit: 256 MB

Score : 300300 points

Problem Statement

We have NN clocks. The hand of the ii-th clock (1≤i≤N)(1≤i≤N) rotates through 360°360° in exactly TiTi seconds.
Initially, the hand of every clock stands still, pointing directly upward.
Now, Dolphin starts all the clocks simultaneously.
In how many seconds will the hand of every clock point directly upward again?

Constraints

  • 1≤N≤1001≤N≤100
  • 1≤Ti≤10181≤Ti≤1018
  • All input values are integers.
  • The correct answer is at most 10181018 seconds.

Input

Input is given from Standard Input in the following format:

NN
T1T1
::
TNTN

Output

Print the number of seconds after which the hand of every clock point directly upward again.


Sample Input 1 Copy

Copy
2
2
3

Sample Output 1 Copy

Copy
6

We have two clocks. The time when the hand of each clock points upward is as follows:

  • Clock 11224466...... seconds after the beginning
  • Clock 22336699...... seconds after the beginning

Therefore, it takes 66 seconds until the hands of both clocks point directly upward.


Sample Input 2 Copy

Copy
5
2
5
10
1000000000000000000
1000000000000000000

Sample Output 2 Copy

Copy
1000000000000000000

最小公倍数,代码不能再短了

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{ int n;
cin>>n;
LL s=;
for(int i=;i<n;i++){
LL x;
cin>>x;
s=x/__gcd(x,s)*s;
}
cout<<s<<endl;
return ;
}
D - Transit Tree Path

Time Limit: 2 sec / Memory Limit: 256 MB

Score : 400400 points

Problem Statement

You are given a tree with NN vertices.
Here, a tree is a kind of graph, and more specifically, a connected undirected graph with N−1N−1 edges, where NN is the number of its vertices.
The ii-th edge (1≤i≤N−1)(1≤i≤N−1) connects Vertices aiai and bibi, and has a length of cici.

You are also given QQ queries and an integer KK. In the jj-th query (1≤j≤Q)(1≤j≤Q):

  • find the length of the shortest path from Vertex xjxj and Vertex yjyj via Vertex KK.

Constraints

  • 3≤N≤1053≤N≤105
  • 1≤ai,bi≤N(1≤i≤N−1)1≤ai,bi≤N(1≤i≤N−1)
  • 1≤ci≤109(1≤i≤N−1)1≤ci≤109(1≤i≤N−1)
  • The given graph is a tree.
  • 1≤Q≤1051≤Q≤105
  • 1≤K≤N1≤K≤N
  • 1≤xj,yj≤N(1≤j≤Q)1≤xj,yj≤N(1≤j≤Q)
  • xj≠yj(1≤j≤Q)xj≠yj(1≤j≤Q)
  • xj≠K,yj≠K(1≤j≤Q)xj≠K,yj≠K(1≤j≤Q)

Input

Input is given from Standard Input in the following format:

NN
a1a1 b1b1 c1c1
::
aN−1aN−1 bN−1bN−1 cN−1cN−1
QQ KK
x1x1 y1y1
::
xQxQ yQyQ

Output

Print the responses to the queries in QQ lines.
In the jj-th line j(1≤j≤Q)j(1≤j≤Q), print the response to the jj-th query.


Sample Input 1 Copy

Copy
5
1 2 1
1 3 1
2 4 1
3 5 1
3 1
2 4
2 3
4 5

Sample Output 1 Copy

Copy
3
2
4

The shortest paths for the three queries are as follows:

  • Query 11: Vertex 22 → Vertex 11 → Vertex 22 → Vertex 44 : Length 1+1+1=31+1+1=3
  • Query 22: Vertex 22 → Vertex 11 → Vertex 33 : Length 1+1=21+1=2
  • Query 33: Vertex 44 → Vertex 22 → Vertex 11 → Vertex 33 → Vertex 55 : Length 1+1+1+1=41+1+1+1=4

Sample Input 2 Copy

Copy
7
1 2 1
1 3 3
1 4 5
1 5 7
1 6 9
1 7 11
3 2
1 3
4 5
6 7

Sample Output 2 Copy

Copy
5
14
22

The path for each query must pass Vertex K=2K=2.


Sample Input 3 Copy

Copy
10
1 2 1000000000
2 3 1000000000
3 4 1000000000
4 5 1000000000
5 6 1000000000
6 7 1000000000
7 8 1000000000
8 9 1000000000
9 10 1000000000
1 1
9 10

Sample Output 3 Copy

Copy
17000000000

这个题哪有那么多幺蛾子,直接递归上去就好了

#include <bits/stdc++.h>
using namespace std;
const int N=;
typedef long long ll;
struct to{
ll l,t;
};
vector<to> mp[N];
ll dis[N];
void dfs(ll u,ll fa){
for(ll i=; i<mp[u].size(); i++){
ll v=mp[u][i].t;
if(v==fa) continue;
dis[v]=dis[u]+mp[u][i].l;
dfs(v,u);
}
return;
}
int main(){
ll n,a,b,c,q,k,x,y;
cin>>n;
for(ll i=; i<n; i++){
cin>>a>>b>>c;
mp[a].push_back((to){c,b});
mp[b].push_back((to){c,a});
}
cin>>q>>k;
dfs(k,);
for(ll i=; i<q; i++){
cin>>x>>y;
cout<<dis[x]+dis[y]<<endl;
}
return ;
}

AtCoder Beginner Contest 070的更多相关文章

  1. Atcoder Beginner Contest 070 D - Transit Tree Path

    题意:n个点,n-1条边,组成一个无向的联通图,然后给出q和k,q次询问,每次给出两个点,问这两个点之间的最短距离但必须经过k点. 思路:我当时是用优化的Dijkstra写的(当天刚学的),求出k点到 ...

  2. AtCoder Beginner Contest 070|Elena|8.12|#471

    打了场beginner的AtCoder,也是我第一次打AtCoder,虽然AK了,但是由于手速慢+撒比,才#471… 比赛链接:https://beta.atcoder.jp/contests/abc ...

  3. AtCoder Beginner Contest 070 ABCD题

    题目链接:http://abc070.contest.atcoder.jp/assignments A - Palindromic Number Time limit : 2sec / Memory ...

  4. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  5. AtCoder Beginner Contest 052

    没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...

  6. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  7. AtCoder Beginner Contest 136

    AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...

  8. AtCoder Beginner Contest 137 F

    AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...

  9. AtCoder Beginner Contest 076

    A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...

随机推荐

  1. Azure 门户使用概览

    Azure 门户是管理 Azure 云平台的核心工具,用户可以在其中预配和管理 Azure 资源.本教程将帮助你熟悉Azure管理门户,包括一些关键功能的介绍,并演示了如何通过 Azure 门户创建虚 ...

  2. 巧用代理设计模式(Proxy Design Pattern)改善前端图片加载体验

    这篇文章介绍一种使用代理设计模式(Proxy Design Pattern)的方法来改善您的前端应用里图片加载的体验. 假设我们的应用里需要显示一张尺寸很大的图片,位于远端服务器.我们用一些前端框架的 ...

  3. vue axios 请求 https 的特殊处理

    最近遇到自签发的CA证书,在前端axios请求https请求时,无法自动加载证书. 解决方法:将无法加载的请求在浏览器新窗口手动加载,选择继续连接. 重新加载,问题解决. 根本原因:因为自签发证书,浏 ...

  4. Java中的Static修饰符

    static(静态.修饰符):static修饰成员变量时:static修饰成员变量时,那么该成员变量的数据就是一个共享的数据. 静态成员变量的访问方式:方式一: 使用对象进行访问. 对象.属性名 方式 ...

  5. Cordova 本地项目创建方法

    l  创建项目 需要在终端上输入:cordova create [目录][项目ID][APP名称] 运行:cordova create hello com.example.hello hello 将在 ...

  6. RabbitMQ 学习资料

    https://www.rabbitmq.com/getstarted.html http://www.cnblogs.com/luxiaoxun/p/3918054.html http://back ...

  7. 禅与 Objective-C 编程艺术(Zen and the Art of the Objective-C Craftsmanship)

    英文版Zen and the Art of the Objective-C Craftsmanshiphttps://github.com/objc-zen/objc-zen-book 中文版禅与 O ...

  8. 一句话懂什么是JS闭包

    无论何时声明新函数并将其赋值给变量,都要存储函数定义和闭包.闭包包含在函数创建时作用域中的所有变量,它类似于背包.函数定义附带一个小背包,它的包中存储了函数定义创建时作用域中的所有变量. 我将永远记住 ...

  9. 51nod——2489 小b和灯泡(打表/平方数)

    这题打表去找因子的个数然后判奇偶也行.预处理O(n) 扫一遍判断O(n). ; i * i <= n; i++){ for(int j = i; i * j <= n; j++){ div ...

  10. 救援(BFS)

    题目描述: 在你的帮助下,Oliver终于追到小X了,可有一天,坏人把小X抓走了.这正是Oliver英雄救美的时候.所以,Oliver又找到哆啦A梦,借了一个机器,机器显示出一幅方格地图,它告诉Oli ...