当前位置: 首页 > wzjs >正文

临沂城乡建设管理局网站免费网络推广网址

临沂城乡建设管理局网站,免费网络推广网址,wordpress 付费下载,淮南寿县题目链接:https://codeforces.com/contest/2070 A. FizzBuzz Remixed 思路: 要使得x mod 3 x mod 5,很明显当x是15的倍数时满足 再观察可以知道,当x 15*k m (m为0 1 2) 时都满足条件 故可写码了 代码: //#in…

题目链接:https://codeforces.com/contest/2070

A. FizzBuzz Remixed

思路:

要使得x mod 3 == x mod 5,很明显当x是15的倍数时满足

再观察可以知道,当x = 15*k + m (m为0 1 2) 时都满足条件

故可写码了

代码:

//#include <iostream>
//#include <algorithm>
//#include<cstring>
//#include<cctype>
//#include<string>
//#include <set>
//#include <vector>
//#include <cmath>
//#include <queue>
//#include <unordered_set>
//#include <map>
//#include <unordered_map>
//#include <stack>
//#include <memory>
//using namespace std;
//#define ll long long
//#define yes cout << "YES" << endl
//#define no cout << "NO" << endl
//
(0 1 3 4 6 7 9) * 3
//
//void solve()
//{
//    int n;
//    cin >> n;
//    ll ans = 0;
//    ans += (n / 15+1) * 3;
//    for (int j = 0; j < 3; j++)
//    {
//        if (15 * (n / 15) + j > n)
//        {
//            ans--;
//        }
//    }
//    cout << ans << endl;
//}
//
//int main()
//{
//    //for (int i = 0; i <= 1000; i++)
//    //{
//    //    if (i >= 0 && i % 3 == i % 5)
//    //        cout << i << endl;
//    //}
//    cin.tie(0)->sync_with_stdio(false);
//    int t = 1;
//    cin >> t;
//    while (t--)
//    {
//        solve();
//    }
//    return 0;
//}

B. Robot Program

思路:

模拟一下即可,先判断能不能回到0点,如果可以会到0点,那么再判断一下能不能再次回到0点,如果能,就能得到步数k,之后直接除即可

代码:

//#include <iostream>
//#include <algorithm>
//#include<cstring>
//#include<cctype>
//#include<string>
//#include <set>
//#include <vector>
//#include <cmath>
//#include <queue>
//#include <unordered_set>
//#include <map>
//#include <unordered_map>
//#include <stack>
//#include <memory>
//using namespace std;
//#define ll long long
//#define yes cout << "YES" << endl
//#define no cout << "NO" << endl
//
//void solve()
//{
//    ll n, x, k;
//    cin >> n >> x >> k;
//    string s;
//    cin >> s;
//    int time1 = 0;
//    for (int i = 0; i < n; i++)
//    {
//        x += (s[i] == 'L') ? -1 : 1;
//        if (x == 0)
//        {
//            time1 = 1+i;
//            break;
//        }
//    }
//    int time2 = 0;
//    for (int i = 0; i < n; i++)
//    {
//        x += (s[i] == 'L') ? -1 : 1;
//        if (x == 0)
//        {
//            time2 = 1 + i;
//            break;
//        }
//    }
//    ll ans = 0;
//    if (time1 != 0)
//    {
//        ans++;
//        k -= time1;
//        if(time2)
//        ans += k / time2;
//    }
//    cout << ans << endl;
//}
//
//int main()
//{
//    cin.tie(0)->sync_with_stdio(false);
//    int t = 1;
//    cin >> t;
//    while (t--)
//    {
//        solve();
//    }
//    return 0;
//}

C. Limited Repainting

思路:

一道二分+贪心的题目

我们可以二分答案,然后check一下是否满足,那么难点就在于check函数了

现在我们假设答案为mid,那么就有以下几种情况

① s[i] = B

如果a[i] < mid,如果我们还没开始涂,那我们跳过即可,因为最后的答案是取所有a[i]的最大值,此时不涂对答案也没影响,如果我们前面已经涂了,那么再涂这个也无妨,因为涂的越多肯定越好,比如有

BBB

mid mid-1 mid

那我们如果不涂第二个的话,我们就至少需要两次才能满足,但是涂了第二个一次就能连续涂完

否则我们必须涂

② s[i] = R

如果我们还没开始涂,那么直接跳过即可

否则,如果a[i] > mid,我们就不能涂,因为此时答案就不为mid了,否则直接涂就行,理由同上,多涂更好

代码:

//#include <iostream>
//#include <algorithm>
//#include<cstring>
//#include<cctype>
//#include<string>
//#include <set>
//#include <vector>
//#include <cmath>
//#include <queue>
//#include <unordered_set>
//#include <map>
//#include <unordered_map>
//#include <stack>
//#include <memory>
//using namespace std;
//#define ll long long
//#define yes cout << "YES" << endl
//#define no cout << "NO" << endl
//
//void solve()
//{
//    int n, k;
//    cin >> n >> k;
//    string s;
//    cin >> s;
//    vector<int> a(n);
//    for (int i = 0; i < n; i++)
//    {
//        cin >> a[i];
//    }
//    int l = 0, r = 1e9+1;
//    auto check = [&](int mid) -> bool
//        {
//            int cnt = 0;
//            for (int i = 0; i < n; i++)
//            {
//                if (a[i] > mid && s[i] !='R')
//                {
//                    int j = i + 1;
//                    while (j < n && (s[j] == 'B' || a[j] <= mid))
//                    {
//                        j++;
//                    }
//                    i = j - 1;
//                    cnt++;
//                }
//            }
//            return cnt <= k;
//        };
//    while (l < r)
//    {
//        int mid = (l+r) / 2;
//        if (check(mid))
//        {
//            r = mid;
//        }
//        else
//        {
//            l = mid+1;
//        }
//    }
//    cout << r << endl;
//}
//
//int main()
//{
//    cin.tie(0)->sync_with_stdio(false);
//    int t = 1;
//    cin >> t;
//    while (t--)
//    {
//        solve();
//    }
//    return 0;
//}

D. Tree Jumps

思路:

首先要理解题意,我们只能从 当前节点 跳至 非自身子节点 的 节点

那我们可以反过来考虑,对于任意一个节点,有多少方式跳过来

我们可以分层考虑

对于根节点(第一层)只有一种

对于第二层也是只有一种,因为有且只能从根节点跳过来(题目中的特例)

对于第三层的节点,任意一个节点的跳法有 node[i].val = sum[2] - node[node[i].father].val 种

其中sum[i]为第i层所有节点的跳法总和,node[i].val为节点i的跳法

同理,对于第n层也是这样

那么最后的答案就为每层sum之和

(这里要注意大数取模)

代码:

//#include <iostream>
//#include <algorithm>
//#include <cstring>
//#include <cctype>
//#include <string>
//#include <set>
//#include <vector>
//#include <cmath>
//#include <queue>
//#include <unordered_set>
//#include <map>
//#include <unordered_map>
//#include <stack>
//#include <memory>
//using namespace std;
//
//const int MOD = 998244353;
//
//struct Z {
//    long long val;
//    Z(long long v = 0) : val(v% MOD) {
//        if (val < 0) val += MOD;
//    }
//    Z& operator+=(const Z& other) {
//        val = (val + other.val) % MOD;
//        return *this;
//    }
//    Z& operator-=(const Z& other) {
//        val = (val - other.val + MOD) % MOD;
//        return *this;
//    }
//    Z& operator*=(const Z& other) {
//        val = (val * other.val) % MOD;
//        return *this;
//    }
//    friend Z operator+(Z a, const Z& b) { return a += b; }
//    friend Z operator-(Z a, const Z& b) { return a -= b; }
//    friend Z operator*(Z a, const Z& b) { return a *= b; }
//    friend ostream& operator<<(ostream& os, const Z& z) {
//        return os << z.val;
//    }
//};
//
//struct MyStruct
//{
//    int father = -1;
//    int dep = 1;
//    Z val = 0; // 修改为Z类型
//    int self = 1;
//};
//
//void solve()
//{
//    int n;
//    cin >> n;
//    vector<MyStruct> node(n + 1);
//    int maxdep = 0;
//    node[1].val = 1; // 隐式转换为Z
//    for (int i = 2; i <= n; i++)
//    {
//        cin >> node[i].father;
//        node[i].dep = node[node[i].father].dep + 1;
//        node[i].self = i;
//        maxdep = max(maxdep, node[i].dep);
//    }
//    vector<vector<MyStruct>> depnode(maxdep + 1);
//    vector<Z> depSum(maxdep + 1, 0); // 改为vector<Z>
//    for (int i = 1; i <= n; i++)
//    {
//        depnode[node[i].dep].push_back(node[i]);
//    }
//    depSum[1] = 1;
//    for (int i = 2; i <= maxdep; i++)
//    {
//        for (size_t j = 0; j < depnode[i].size(); j++)
//        {
//            if (i == 2)
//                node[depnode[i][j].self].val = 1;
//            else
//                node[depnode[i][j].self].val = depSum[i - 1] - node[depnode[i][j].father].val;
//            depSum[i] += node[depnode[i][j].self].val;
//        }
//    }
//    Z ans = 0; // 改为Z类型
//    for (int i = 1; i <= maxdep; i++)
//    {
//        ans += depSum[i];
//    }
//    cout << ans << endl;
//}
//
//int main()
//{
//    cin.tie(0)->sync_with_stdio(false);
//    int t = 1;
//    cin >> t;
//    while (t--)
//    {
//        solve();
//    }
//    return 0;
//}

http://www.dtcms.com/wzjs/29775.html

相关文章:

  • 做网站添加支付功能要多少钱百度排名优化工具
  • 宁波手机网站制作资源搜索引擎
  • 上海网站开发定制简单的seo
  • 建设部网站怎么查询企业业绩手机端搜索引擎排名
  • 成都鱼羊环保网站制作设计产品线上推广方式都有哪些
  • 做网站的哪家公司好seo优化专家
  • 数字营销网站seo博客网址
  • 中国工商银行官网四年级下册数学优化设计答案
  • 做网络推广选择哪个网站好如何自建网站
  • 网站建设开放的端口百度关键词工具在哪里
  • 制作一个网站需要注意什么网络营销论文题目
  • 网站建设 八羊百度手机助手app
  • 成都公司的网站制作合肥网站关键词优化公司
  • 做seo网站公司哪家好网络营销专员的就业前景
  • 石家庄建设集团网站网站在线制作
  • 做诚信通谁给做网站广告公司起名大全最新
  • 咨询公司网站免费自己建网站
  • 网站建设相关图片厦门seo结算
  • 网站开发需要考虑哪些方面考证培训机构
  • 济南论坛网站建设搜索率最高的关键词
  • 长沙做网站找哪家好哪些网站可以发广告
  • 网站开发的编程语言手游推广赚佣金的平台
  • 个性网站功能软文营销的五个步骤
  • 两学一做 山西答题网站线上推广外包公司
  • 品牌创意网站建设徕卡e网络营销公司名字大全
  • 做网站需学什么条件百度保障平台 客服
  • 宜兴公司做网站免费的精准引流软件
  • wordpress浏览器兼容深圳seo优化公司
  • 平谷手机网站建设seo
  • 做短视频的网站太原百度关键词优化