Codeforces Round #384 (Div. 2) 水题解题报告

来源:互联网 发布:初中化学仿真实验软件 编辑:程序博客网 时间:2024/05/22 12:57

这场单div2略水,E题本来想暴力怼怼怕过不了就没写,结果发现n才1000,后悔啊
D题没看得懂q巨的一句话题解的意思
下面是前三题的代码


743A-Vladik and flights

Vladik is a competitive programmer. This year he is going to win the International Olympiad in Informatics. But it is not as easy as it sounds: the question Vladik face now is to find the cheapest way to get to the olympiad….

题意就是你从a到b,如果数字相同花费为0,不同花费为编号差,求最小花费。
刚开始模拟杠这道题被hack推了一下发现必然只有0和1两种情况,判断一下就好了

#include<bits/stdc++.h>using namespace std;int main(){    int n,a,b;    string s;    cin>>n>>a>>b;    cin>>s;    if(s[a]==s[b])        cout<<"0"<<endl;    else        cout<<"1"<<endl;    return 0;}

743B-Chloe and the sequence

Chloe, the same as Vladik, is a competitive programmer. She didn’t have any problems to get to the olympiad like Vladik, but she was confused by the task proposed on the olympiad…

构造一个1213121412131215121312141213121…
输入n,k,求k位置的数。
推了一下发现和n无关一个长度很长的序列构造肯定不行,每次对除以二直到第一次不能整除。

#include<bits/stdc++.h>typedef long long ll;using namespace std;int main(){    ll b,a,ans=1;    cin>>b>>a;    while(a%2==0)    {        a/=2;        ans++;    }    cout<<ans<<endl;    return 0;}

743C-Vladik and fractions

Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction 2/n as a sum of three distinct positive fractions in form 1/m…

题意就是给你一个2/n,让你构造出三个埃及分数。

听csy在群里说一下2/n=1/n+1/(n+1)+1/(n^2+n)
一下子全世界都会写这题了,注意n=1的时候要输出-1

#include<bits/stdc++.h>using namespace std;typedef long long ll;int main(){    ///2/n=1/n+1/(n+1)+1/(n^2+n)    ll a;    cin>>a;    if(a==1)        cout<<"-1"<<endl;    else if(a==2)        cout<<"2 3 6"<<endl;    else if(a==3)        cout<<"2 7 42"<<endl;    else        cout<<a<<" "<<a+1<<" "<<a*(a+1)<<endl;    return 0;}
0 0
原创粉丝点击