为什么最近不怎么发博客了?主要是因为我还是太菜了,做不了几个题。今天的这篇博客就简单来搞搞前面这段时间做的所有的题。题目大标题就按照做题顺序写了,这个标题并不是题目的难度!!

A题

题目链接

Problem Statement

Does  hold?

Constraints

  • n is an integer between 1 and  (inclusive).

Input

Input is given from Standard Input in the following format:

n

Output

If , print Yes; otherwise, print No.


Sample Input 1

5

Sample Output 1

Yes

Since , we have , so Yes should be printed.


Sample Input 2

2

Sample Output 2

No

For n=2, we have , so  does not hold. Thus, No should be printed.


Sample Input 3

623947744

Sample Output 3

Yes

题解:

        是谁这个题就错了两次?是我!!很明显,n=2,3,4时不满足要求,其余均满足要求。

AC代码:

#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <deque>
#include <set>
#define ll long long
#define PI acos(-1)
using namespace std;
const int N=1e5+5;
int a[N];
void solve()
{int n;scanf("%d",&n);if (n!=2&&n!=3&&n!=4)puts("Yes");elseputs("No");
}int main()
{solve();return 0;
}

B题

题目链接

Problem Statement

We have a circular pizza.
Takahashi will cut this pizza using a sequence A of length N, according to the following procedure.

  • First, make a cut from the center in the 12 o'clock direction.
  • Next, do N operations. The i-th operation is as follows.
    • Rotate the pizza Ai​ degrees clockwise.
    • Then, make a cut from the center in the 12 o'clock direction.

For example, if A=(90,180,45,195), the procedure cuts the pizza as follows.

Find the center angle of the largest pizza after the procedure.

Constraints

  • All values in input are integers.
  • 1≤N≤359
  • 1≤Ai​≤359
  • There will be no multiple cuts at the same position.

Input

Input is given from Standard Input in the following format:

N
A1​ A2​ … AN​

Output

Print the answer as an integer.


Sample Input 1

4
90 180 45 195

Sample Output 1

120

This input coincides with the example in the Problem Statement.
The center angle of the largest pizza is 120 degrees.


Sample Input 2

1
1

Sample Output 2

359

Sample Input 3

10
215 137 320 339 341 41 44 18 241 149

Sample Output 3

170

题解:

这道题目还是比较容易的,很容易就能想到要用类似于前缀和的思想,在这里需要模上360(这个自己画画图就能知道),排序后去维护这个数组,就能得到答案了。

AC代码:

#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <deque>
#include <set>
#define ll long long
#define PI acos(-1)
using namespace std;
const int N=400;
int a[N],deg[N];
void solve()
{int n;scanf("%d",&n);deg[n+1]=360;for (int i=1;i<=n;i++){scanf("%d",&a[i]);deg[i]=(deg[i-1]+a[i])%360;}sort(deg+1,deg+n+1);int ans=0;for (int i=1;i<=n+1;i++)ans=max(ans,deg[i]-deg[i-1]);cout<<ans<<endl;
}int main()
{solve();return 0;
}

C题

题目链接

Problem Statement

Takahashi wants to send a letter to Santa Claus. He has an envelope with an X-yen (Japanese currency) stamp stuck on it.
To be delivered to Santa Claus, the envelope must have stamps in a total value of at least Y yen.
Takahashi will put some more 10-yen stamps so that the envelope will have stamps worth at least Y yen in total.
At least how many more 10-yen stamps does Takahashi need to put on the envelope?

Constraints

  • X and Y are integers.
  • 1≤X,Y≤1000

Input

Input is given from Standard Input in the following format:

X Y

Output

Print the answer as an integer.


Sample Input 1

80 94

Sample Output 1

2
  • After adding zero 10-yen stamps to the 80-yen stamp, the total is 80 yen, which is less than the required amount of 94 yen.
  • After adding one 10-yen stamp to the 80-yen stamp, the total is 90 yen, which is less than the required amount of 94 yen.
  • After adding two 10-yen stamps to the 80-yen stamp, the total is 100 yen, which is not less than the required amount of 94 yen.

Sample Input 2

1000 63

Sample Output 2

0

The envelope may already have a stamp with enough value.


Sample Input 3

270 750

Sample Output 3

48

题解:

        额……这道题目没什么可说的,相减除以10向上取整就行。

AC代码:

#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <deque>
#include <set>
#define ll long long
#define PI acos(-1)
using namespace std;void solve()
{int x,y;cin>>x>>y;if (x>=y)cout<<"0"<<endl;elsecout<<((y-x)%10==0?(y-x)/10:(y-x)/10+1)<<endl;
}int main()
{solve();return 0;
}

D题

题目链接

Problem Statement

You are given integers L, R, and a string S consisting of lowercase English letters.
Print this string after reversing (the order of) the L-th through R-th characters.

Constraints

  • S consists of lowercase English letters.
  • 1≤∣S∣≤ (∣S∣ is the length of S.)
  • L and R are integers.
  • 1≤L≤R≤∣S∣

Input

Input is given from Standard Input in the following format:

L R
S

Output

Print the specified string.


Sample Input 1

3 7
abcdefgh

Sample Output 1

abgfedch

After reversing the 3-rd through 7-th characters of abcdefgh, we have abgfedch.


Sample Input 2

1 7
reviver

Sample Output 2

reviver

The operation may result in the same string as the original.


Sample Input 3

4 13
merrychristmas

Sample Output 3

meramtsirhcyrs

题解:

额……这道题也没啥可说的,直接使用string容器中的reverse函数就行。

AC代码:

#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <deque>
#include <set>
#define ll long long
#define PI acos(-1)
using namespace std;void solve()
{int l,r;string s;cin>>l>>r;cin>>s;reverse(s.begin()+l-1,s.begin()+r);cout<<s;
}int main()
{solve();return 0;
}

E题

题目链接

Given a positive integer n, determine if  is an infinite decimal in decimal base. If the answer is yes, print "Yes" in a single line, or print "No" if the answer is no.

Input

The first line contains one positive integer T (1≤T≤100), denoting the number of test cases.

For each test case:

Input a single line containing a positive integer n (1≤n≤100).

Output

Output T lines each contains a string "Yes" or "No", denoting the answer to corresponding test case.

Example

input

2
5
3

output

No
Yes

Note

=0.2, which is a finite decimal.

=0.333⋯, which is an infinite decimal.


题解:

这道题其实是有个正经的解法的,但就本题而言,考虑到范围只有1~100,直接暴力取就行,很显然,只有几个解是非循环的,单独拿出来判断就行。

AC代码:

#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <deque>
#include <set>
#define ll long long
#define PI acos(-1)
using namespace std;void solve()
{int t;cin>>t;while (t--){int n;cin>>n;if (n==1||n==2||n==4||n==5||n==8||n==10||n==16||n==20||n==25||n==32||n==40||n==50||n==64||n==80||n==100)cout<<"No"<<endl;elsecout<<"Yes"<<endl;}
}int main()
{solve();return 0;
}

F题

题目链接

Problem Statement

Takahashi melted and mixed A grams of gold and B grams of silver (0≤A,B, 0<A+B) to produce new metal.

What metal did he produce: pure gold, pure silver, or an alloy?

Formally, the product is called as follows.

  • Pure gold, if 0<A and B=0.
  • Pure silver, if A=0 and 0<B.
  • An alloy, if 0<A and 0<B.

Constraints

  • 0≤A,B≤100
  • 1≤A+B
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B

Output

If the product is pure gold, print Gold; if it is pure silver, print Silver; if it is an alloy, print Alloy.


Sample Input 1

50 50

Sample Output 1

Alloy

We have 0<A and 0<B, so the product is an alloy.


Sample Input 2

100 0

Sample Output 2

Gold

We have 0<A and B=0, so the product is pure gold.


Sample Input 3

0 100

Sample Output 3

Silver

We have A=0 and 0<B, so the product is pure silver.


Sample Input 4

100 2

Sample Output 4

Alloy

题解:

        额……这道题没啥可说的,直接上代码。

AC代码:

#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <deque>
#include <set>
#define ll long long
#define PI acos(-1)
using namespace std;void solve()
{int a,b;cin>>a>>b;if (a==0)cout<<"Silver";else if (b==0)cout<<"Gold";elsecout<<"Alloy";
}int main()
{solve();return 0;
}

G题

题目链接

Problem Statement

You are given a 4-digit PIN: X1​X2​X3​X4​, which may begin with a 0. The PIN is said to be weak when it satisfies one of the following conditions:

  • All of the four digits are the same.
  • For each integer ii such that 1≤i≤3, Xi+1​ follows Xi​. Here, j+1 follows j for each 0≤j≤8, and 0 follows 9.

If the given PIN is weak, print Weak; otherwise, print Strong.

Constraints

  • 0≤X1​,X2​,X3​,X4​≤9
  • X1​, X2​, X3​, andX4​ are integers.

Input

Input is given from Standard Input in the following format:

X1​X2​X3​X4​

Output

If the given PIN is weak, print Weak; otherwise, print Strong.


Sample Input 1

7777

Sample Output 1

Weak

All four digits are 7, satisfying the first condition, so this PIN is weak.


Sample Input 2

0112

Sample Output 2

Strong

The first and second digits differ, and the third digit does not follow the second digit, so neither condition is satisfied.


Sample Input 3

9012

Sample Output 3

Weak

Note that 0 follows 9.


题解:

这道题目其实可以直接把所有weak的解单独存放在一个vector容器里,与输入的字符串进行比较就能得到结果。

AC代码:

#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <deque>
#include <set>
#define ll long long
#define PI acos(-1)
using namespace std;void solve()
{vector<string> v;v.push_back("0123");v.push_back("1234");v.push_back("2345");v.push_back("3456");v.push_back("4567");v.push_back("5678");v.push_back("6789");v.push_back("7890");v.push_back("8901");v.push_back("9012");string s;cin>>s;bool f=0;if (s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3])f=1;for (int i=0;i<v.size();i++){if (s==v[i]){f=1;break;}}if (f)cout<<"Weak";elsecout<<"Strong";
}int main()
{solve();return 0;
}

H题

题目链接

Problem Statement

You are given two sequences: A=(A1​,A2​,…,AN​) consisting of N positive integers, and B=(B1​,…,BM​) consisting of M positive integers.

Find the minimum difference of an element of A and an element of B, that is, 1≤i≤Nmin​1≤j≤Mmin​∣Ai​−Bj​∣.

Constraints

  • 1≤N,M≤2×
  • 1≤Ai​≤
  • 1≤Bi​≤
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
A1​ A2​ … AN​
B1​ B2​ … BM​

Output

Print the answer.


Sample Input 1

2 2
1 6
4 9

Sample Output 1

2

Here is the difference for each of the four pair of an element of A and an element of B: ∣1−4∣=3, ∣1−9∣=8, ∣6−4∣=2, and ∣6−9∣=3. We should print the minimum of these values, or 2.


Sample Input 2

1 1
10
10

Sample Output 2

0

Sample Input 3

6 8
82 76 82 82 71 70
17 39 67 2 45 35 22 24

Sample Output 3

3

题解:

        这道题看似是一个O()复杂度的题,实际上没那么麻烦。首先先对两个数组进行排序,然后从第一项开始取最小的差值,如果当前a数组的数比b数组的数大,则b数组的指针向后移动一个,反之则移动a数组的指针。具体的原因是因为减去一个更大的数只会让这个差值越来越大造成的,所以我们只需要在每次计算的时候移动数组的指针就行。

AC代码:

#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <deque>
#include <set>
#define ll long long
#define PI acos(-1)
using namespace std;
const int N=2e5+5;
int a[N],b[N];void solve()
{int n,m;cin>>n>>m;for (int i=0;i<n;i++)cin>>a[i];for (int i=0;i<m;i++)cin>>b[i];sort(a,a+n);sort(b,b+m);int ans=1e9+5;int x=0,y=0;while (x<n&&y<m){ans=min(ans,abs(a[x]-b[y]));if (a[x]>b[y])y++;elsex++;}cout<<ans;
}int main()
{solve();return 0;
}

ps:本人实力较菜,只能做出这些简单题,后面的题如果有哪位大神可以解决可以私信我,如果这里面有讲的不清楚或者有错误的,望及时指出!

寒假养成计划——Day9相关推荐

  1. 寒假养成计划——Day2

    A题 题目链接 You have an n×n chessboard and k rooks. Rows of this chessboard are numbered by integers fro ...

  2. Girls In AI:面向编程零基础女孩子的AI算法工程师养成计划

    Github:YZHANG1270/Girls-In-AI Coding is the new sexy. GirlsInAI(GIA) 是一个面向编程 零基础 的AI算法工程师养成计划.鼓励更多的女 ...

  3. BZOJ 4212: 神牛的养成计划

    4212: 神牛的养成计划 Time Limit: 10 Sec  Memory Limit: 512 MB Submit: 142  Solved: 30 [Submit][Status][Disc ...

  4. 2018寒假学习计划

    所选课程: 浙江大学翁恺教师: 面对对象程序设计C++ 理由: 笔者所选课程其实是看到了Lhy同学已贴的博客,便去寻得了这一课程.在此感谢Lhy同学 从评论来看,此课程授课条理清晰,简明扼要,属于笔者 ...

  5. 正式启动|2020腾讯犀牛鸟云开发校园技术布道师养成计划

    为顺应信息技术行业发展趋势及人才需求,促进新时代云计算领域人才培养,在信息技术新工科产学研联盟的指导下,由腾讯云.腾讯高校合作和图灵教育联合主办,牛客网协办的2020腾讯犀牛鸟云开发校园技术布道师养成 ...

  6. (转)游戏程序员养成计划 (更新2010.11.6)

    游戏程序员养成计划 (更新2010.11.6) 原文地址:http://www.cnblogs.com/clayman/archive/2009/05/17/1459001.html#2241553 ...

  7. 2021腾讯犀牛鸟校园布道师养成计划丨百校同行

    千里之行,基于硅步:万里之船,成于罗盘.2021腾讯犀牛鸟云开发新生工程教育"百校同行"--「云开发校园布道师养成计划」 正式回归! 本次布道师养成计划为高校学生打造的高自由度学习 ...

  8. 【周记】腾讯犀牛鸟「云开发」校园技术布道师养成计划

    一个月前开始试着学习微信小程序 恰好腾讯举办了这个[腾讯犀牛鸟「云开发」校园技术布道师养成计划]https://www.bilibili.com/read/cv4965254这个活动 技术增长 抛开活 ...

  9. 获奖结果公布|2020腾讯犀牛鸟云开发校园技术布道师养成计划

    导语: 为顺应信息技术行业发展趋势及人才需求,促进新时代云计算领域人才培养,在信息技术新工科产学研联盟的指导下,由腾讯云.腾讯高校合作和图灵教育联合主办,牛客网协办的2020腾讯犀牛鸟云开发校园技术布 ...

最新文章

  1. Linux上部署、安装nodejs
  2. 语言关键字特别注意没有_从零开始写文本编辑器(三十三):前20名编程语言的关键字...
  3. ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
  4. 4-3逻辑非运算符及案例 4-4
  5. Java架构师必备框架技能核心笔记,工作感悟
  6. P3243 [HNOI2015]菜肴制作(拓扑 + 优先队列)
  7. Objective-C 编程语言官网文档(二)-对象,类以及消息
  8. kotlin面试_Kotlin面试问题
  9. 神经网络学习小记录55——Keras搭建常见分类网络平台(VGG16、MobileNet、ResNet50)
  10. 新ssd硬盘怎么安装efi_如何在PC中升级和安装新的硬盘驱动器或SSD
  11. 项目上线部署发布流程
  12. 通用国籍,民族,亲属关系,证件类型,常见银行数组,可用于选择框,下拉框等
  13. 四则运算之结对作业报告
  14. 搜狗输入法,输英语单词自动提示
  15. C#获取同花顺,问财V(hexin-v)值
  16. 键盘输入盲打训练, 打字练习,打字游戏 打字教程推荐
  17. 系统优化与lvs详解配置、haproxy
  18. Windows环境下OpenSSL下载安装及制作证书
  19. 一个事物两个方面的对比举例_对比属于修辞手法吗
  20. python之父是( )_Python之父加入微软,一开口就知道是老“凡学家”了

热门文章

  1. mysql常用函数整理
  2. 苹果5G芯片研发失败:继续依赖高通,还要担心被起诉?
  3. 中毒解决方法(http://www.xn--******.com)
  4. linux中524端口,liunx下攻击分析及如何通过交换机封端口
  5. R-2R梯形网络 DAC简易的电路
  6. 在Mac系统中将html网页转成PDF格式
  7. 微信备份到云服务器失败是怎么回事,电脑微信备份连接失败的原因(解决利用电脑版微信备份的方法)...
  8. imperva ssl加速卡查询
  9. 创业实践案例课程答案
  10. 【算法学习笔记】64. 枚举法 SJTU OJ 1381 畅畅的牙签