zoukankan      html  css  js  c++  java
  • Daliy Algorithm -- day 99

    Nothing to fear


    种一棵树最好的时间是十年前,其次是现在!

    那些你早出晚归付出的刻苦努力,你不想训练,当你觉的太累了但还是要咬牙坚持的时候,那就是在追逐梦想,不要在意终点有什么,要享受路途的过程,或许你不能成就梦想,但一定会有更伟大的事情随之而来。 mamba out~

    2020.8.4


    人一我十,人十我百,追逐青春的梦想,怀着自信的心,永不言弃!

    Minesweeper

    #include <bits/stdc++.h>
    
    #define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    #define lowbit(x) (x & -x)
    #define PI 3.14159265358979323846264338327950L
    typedef long long ll;
    using namespace std;
    const int MAX = 0x7ffffff;
    int t;
    
    void slove()
    {
    	int n;cin >> n;
    	string s;cin >> s;
    	int ans = 0;
    	for(int i = 1;i < n - 1;i ++)
    	{
    		string l = s.substr(0, i);
    		string r = s.substr(i , n - i);
    		vector<bool> vis(100 , 0);
    		int cnt = 0;
    		for(int i = 0;i < l.size();i ++)
    			vis[l[i] - 'a'] = 1;
    		for(int i = 0;i < r.size();i ++)
    			if(vis[r[i] - 'a']){
    				cnt++;
    				vis[r[i] - 'a'] = 0;
    			}
    		ans = max(cnt , ans);
    	}	
    	cout << ans << endl;
    }
    int main()
    {
    	SIS;
    	slove();
    }
    

    Modsum

    观察推公式

    #include <bits/stdc++.h>
    
    #define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    #define lowbit(x) (x & -x)
    #define PI 3.14159265358979323846264338327950L
    typedef long long ll;
    using namespace std;
    const int MAX = 0x7ffffff;
    int t;
    
    void slove()
    {
    	int n;cin >> n;
    	cout << (ll)n * (n - 1) / 2 << endl;
    }
    int main()
    {
    	SIS;
    	slove();
    }
    
  • 相关阅读:
    IDEA安装及破解永久版教程————鹏鹏
    Hive(2)-Hive的安装,使用Mysql替换derby,以及一丢丢基本的HQL
    Hive(1)-基本概念
    ZooKeeper(3)-内部原理
    Hadoop(25)-高可用集群配置,HDFS-HA和YARN-HA
    ZooKeeper(2)-安装和配置
    ZooKeeper(1)-入门
    Hadoop(24)-Hadoop优化
    Hadoop(23)-Yarn资源调度器
    Hadoop(22)-Hadoop数据压缩
  • 原文地址:https://www.cnblogs.com/wlw-x/p/13436064.html
Copyright © 2011-2022 走看看