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";
  }
}

原文地址:https://www.cnblogs.com/baccano-acmer/p/10199099.html

时间: 2024-10-07 17:09:50

Educational Codeforces Round 57 (Rated for Div. 2) 前三个题补题的相关文章

Educational Codeforces Round 57 (Rated for Div. 2)

get人生第二场CF! 成绩:(exACM) rank858 AC3/7 Penalty57 rating1648(+52) 题目:Educational Codeforces Round 57 (Rated for Div. 2) 错题题解: D. Easy Problem E. The Top Scorer F. Inversion Expectation G. Lucky Tickets 原文地址:https://www.cnblogs.com/xht37/p/10198321.html

Educational Codeforces Round 57 (Rated for Div. 2) ABCDF题解

ZZ出题人写NTT写成ZZ了吧,全是998244353,不需要取模的东西强行取模搞得我以为答案很大想了好久(指B题) A.任意输出 \([l,r]\) 内的一组满足 \(x \mid y\) 的 \(x, y\) ,保证有答案 我输出了 \(\lfloor \frac{r}{l} \rfloor \times l\) 输出2l也行 int main() { int T; in, T; while (T--) { int l, r; in, l, r; out, l, ' ', r / l * l

Educational Codeforces Round 36 (Rated for Div. 2)

Educational Codeforces Round 36 (Rated for Div. 2) F. Imbalance Value of a Tree You are given a tree T consisting of n vertices. A number is written on each vertex; the number written on vertex i is ai. Let's denote the function I(x,?y) as the differ

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars There are n pillars aligned in a row and numbered from 1 to n. Initially each pillar contains exactly one disk. The i-th pillar contains a disk having radius ai. You can move these disks

Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations

原文链接:https://www.cnblogs.com/xwl3109377858/p/11405773.html Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations You are given a sequence of n pairs of integers: (a1,b1),(a2,b2),…,(an,bn). This sequence is called bad if it is

Educational Codeforces Round 36 (Rated for Div. 2) 题解

Educational Codeforces Round 36 (Rated for Div. 2) 题目的质量很不错(不看题解做不出来,笑 Codeforces 920C 题意 给定一个\(1\)到\(n\)组成的数组,只可以交换某些相邻的位置,问是否可以将数组调整为升序的 解题思路 首先如果每个数都能通过交换到它应该到的位置,那么就可以调整为升序的. 但实际上交换是对称的,如果应该在的位置在当前位置前方的数都交换完成,那么整体就是排好序的,因为不可能所有不在相应位置的数都在相应位置的后方.

Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://codeforces.com/contest/985/problem/E Description Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome w

Educational Codeforces Round 55 (Rated for Div. 2)

Educational Codeforces Round 55 (Rated for Div. 2) 链接 A Vasya and Book 傻逼题..注意判边界. #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #include<set> #include<map> #include<vector> #include<cm

Educational Codeforces Round 58 (Rated for Div. 2)(待更新)

get人生第七场CF! 成绩:(exACM) rank AC3/7 Penalty104 rating() 题目:Educational Codeforces Round 58 (Rated for Div. 2) 错题题解: C. Division and Union 原文地址:https://www.cnblogs.com/xht37/p/10260260.html