Educational Codeforces Round 57 (Rated for Div. 2) 前三个题补题
感慨
最终就做出来一个题,第二题差一点公式想错了,又是一波掉分,不过我相信我一定能爬上去的
A Find Divisible(思维)
上来就T了,后来直接想到了题解的O(1)解法,直接输出左边界和左边界*2即可
代码
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long x,y,t;
cin>>t;
while(t--)
{
cin>>x>>y;
cout<<x<<" "<<x*2<<"\n";
}
}
B Substring Removal(思维)
我这里想到了有两种情况,其中第一种情况想的完全是正确的,第二种情况想的公式有问题。正确公式是(l+1) ×(r+1)我当时直接想的是l×r+2
代码
#include <bits/stdc++.h>
using namespace std;
int bk[300],bk1[300],mk[300],p,sum;
long long ans;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n,t1=0,t2=0;
cin>>n;
string a;
cin>>a;
for(int i=0;i<a.size();i++)
bk[a[i]-'a']++;
for(int i=0;i<26;i++)
if(bk[i]>=2)
sum++,mk[p++]=i,bk1[i]++;
for(int i=0;i<a.size();i++)
if(a[i]==a[0])
t1++;
else
break;
for(int i=a.size()-1;i>=0;i--)
if(a[i]==a[a.size()-1])
t2++;
else
break;
if(a[0]==a[a.size()-1])
{
ans=(t1+1)*(t2+1);
ans%=998244353;
cout<<ans;
}
else
cout<<t1+t2+1;
}
C Polygon for the Angle(数学)
完全的数学题,这里得记住这个结论
正多边形中存在的角度的范围是180k/n(其中n是边数,1<=k<=n-2)
这样我们可以求出每个正多边形都有可能有多少度角了
具体直接的算法是运用gcd,其中gnu包含了一个内置的gcd函数__gcd
算出给定的角度与180的gcd,然后用原来的角度/gcd算出了k然后180/gcd算出了n
其中如果k+1==n那么n*=2因为要保证k<=n-2
代码
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--)
{
int ang;
cin>>ang;
int g=__gcd(ang,180);
int k=ang/g;
int n=180/g;
if(k+1==n)
k*=2,n*=2;
cout<<n<<"\n";
}
}
Educational Codeforces Round 57 (Rated for Div. 2) 前三个题补题的更多相关文章
- Educational Codeforces Round 57 (Rated for Div. 2) ABCDEF题解
题目总链接:https://codeforces.com/contest/1096 A. Find Divisible 题意: 给出l,r,在[l,r]里面找两个数x,y,使得y%x==0,保证有解. ...
- Educational Codeforces Round 57 (Rated for Div. 2) D dp
https://codeforces.com/contest/1096/problem/D 题意 给一个串s,删掉一个字符的代价为a[i],问使得s的子串不含"hard"的最小代价 ...
- Educational Codeforces Round 57 (Rated for Div. 2) C 正多边形 + 枚举
https://codeforces.com/contest/1096/problem/C 题意 问是否存在一正多边形内三点构成的角度数为ang,若存在输出最小边数 题解 三点构成的角是个圆周角,假设 ...
- Educational Codeforces Round 57 (Rated for Div. 2)
我好菜啊. A - Find Divisible 好像没什么可说的. #include<cstdio> #include<cstring> #include<algori ...
- Educational Codeforces Round 57 (Rated for Div. 2)D(动态规划)
#include<bits/stdc++.h>using namespace std;char s[100007];long long a[100007];long long dp[100 ...
- Educational Codeforces Round 76 (Rated for Div. 2) A. Two Rival Students 水题
A. Two Rival Students There are
- Educational Codeforces Round 94 (Rated for Div. 2) A. String Similarity (构造水题)
题意:给你一个长度为\(2*n-1\)的字符串\(s\),让你构造一个长度为\(n\)的字符串,使得构造的字符串中有相同位置的字符等于\(s[1..n],s[2..n+1],...,s[n,2n-1] ...
- Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题
Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题 [Problem Description] 总共两次询 ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
随机推荐
- 167. Two Sum II - Input array is sorted (二分ortwo-pointer)
Given an array of integers that is already sorted in ascending order, find two numbers such that the ...
- 【Poj3126】【BNUOJ3245】Prime Path
http://poj.org/problem?id=3126 https://www.bnuoj.com/v3/problem_show.php?pid=3245 题目鬼图 刚开始看到题目的图觉得这题 ...
- hdu1814 Peaceful Commission——2-SAT
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1814 第一次的2-SAT,推荐博客:https://blog.csdn.net/jarjingx/arti ...
- Java 泛型 三
一.泛型初衷 Java集合不会知道我们需要用它来保存什么类型的对象,所以他们把集合设计成能保存任何类型的对象,只要就具有很好的通用性.但这样做也带来两个问题: –集合对元素类型没有任何限制,这样可能引 ...
- 6章 Models
传统的MVC结构中,有模型这么一个概念.Django中,Models又是怎么一回事呢? 刚才生成的这些乱七八糟的数据迁移就是Django自带的一些应用 INSTALLED_APPS = [ 'djan ...
- Commons-FileUpload 常用API
ServerFileUpload类的常用方法 方法名称 方法描述 public void setSizeMax(long sizeMax) 设置请求信息实体内容的最大允许的字节数 public Lis ...
- bzoj 2726: [SDOI2012]任务安排【cdq+斜率优化】
cdq复健.jpg 首先列个n方递推,设sf是f的前缀和,st是t的前缀和: \[ f[i]=min(f[j]+s*(sf[n]-sf[j])+st[i]*(sf[i]-sf[j])) \] 然后移项 ...
- Linux学习系列八:操作网口
一些相对高性能的单片机会带以太网接口,网口在MCU里算是比较复杂的外设了,因为它涉及到网络协议栈,通常情况下网络协议栈会运行在一个RTOS中,所以对普通单片机开发者来说网口使用起来相对难度较大一些.在 ...
- mycat重启报错Failed to connect to the Wrapper at port解决方法
报错信息 ERROR | wrapper | 2018/05/11 14:01:55 | Startup failed: Timed out waiting for a signal from the ...
- Python Turtle绘图
1. 画布(canvas) 画布就是turtle为我们展开用于绘图区域, 我们可以设置它的大小和初始位置 1.1 设置画布大小 turtle.screensize(canvwidth=None, ca ...