zoukankan      html  css  js  c++  java
  • Daliy Algorithm (数学,贪心,思维)-- day 63

    Nothing to fear

    those times when you get up early and you work hard; those times when you stay up late and you work hard; those times when don’t feel like working — you’re too tired, you don’t want to push yourself — but you do it anyway. That is actually the dream. That’s the dream. It’s not the destination, it’s the journey. And if you guys can understand that, what you’ll see happen is that you won’t accomplish your dreams, your dreams won’t come true, something greater will. mamba out


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

    2020.4.22


    Constant Palindrome Sum

    占坑 明天补过程

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstdlib>
    #include <cstring>
    #include <vector>
    #include <cassert>
    #include <string>
    #include <cmath>
    #define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    #define lowbit(x) (x & -x)
    using namespace std;
    typedef long long ll;
    const int N = 200005;
    const int MAX = 0x7ffffff;
    int t;
    void slove()
    {
    	int n , k;
    	cin >> n >> k;
    	vector<int> a(n+1);
    	for(int i = 0;i < n ; ++i)cin >> a[i];
    
    
    	// cnt 数组用于记录 a[i] + a[n-i+1] 出现了多少次
    	vector<int> cnt(2 * k + 1);
    	for(int i = 0;i < n / 2; ++i)
    	{
    		++ cnt[a[i] + a[n-i-1]];
    	}
    	
    	// 得到假设替换这个数这个数可以得到替换得区间
    	
    	vector<int> pref(2 * k + 2);
    	for(int i = 0;i < n / 2;i ++)
    	{
    		int l1 = 1 + a[i],r1 = k + a[i];
    		int l2 = 1 + a[n-i-1],r2 = k + a[n-i-1];
    		if(max(l1,l2) <= min(r1,r2))
    		{
    			++pref[min(l1, l2)];
    			--pref[max(r1, r2) + 1];
    		}else continue;
    	}
    
    	for(int i = 1;i <= 2 * k + 1; ++ i)
    	{
    		cout << pref[i] << " ";
    		pref[i] += pref[i-1];
    	}
    	cout << endl;
    	for(int i = 1;i <= 2 * k + 1; ++ i)
    	{
    		cout << pref[i] << " ";
    	}
    	cout << endl;
    	int ans = 1e9;
    
    	for(int sum = 2; sum <= 2 * k ; ++ sum)
    	{
    		ans = min(ans , (pref[sum] - cnt[sum]) + 
    			(n / 2 - pref[sum]) * 2 );
    	}
    	cout << ans << endl;
    }
    int main()
    {
    	SIS;
    	cin >> t;
    	while(t--)
    	{
    		slove();
    	}
    }
    

    Kana and Dragon Quest game

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstdlib>
    #include <cstring>
    #include <vector>
    #include <cassert>
    #include <string>
    #include <cmath>
    #define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    #define lowbit(x) (x & -x)
    using namespace std;
    typedef long long ll;
    const int MAX = 0x7ffffff;
    int t;
    
    void slove()
    {
    	int n , x , m;
    	cin >> x >> n >> m;
    	while(x > m * 10)
    	{
    		if(n == 0)
    		{
    			cout << "NO" << endl;
    			return;
    		}
    		if(n != 0){
    			x = x / 2 + 10;
    			n--;
    		}
    	}
    	cout << "YES" << endl;
    	return ;
    }
    int main()
    {
    	SIS;
    	cin >> t;
    	while(t--)
    	{
    		slove();
    	}
    }
    

    Ichihime and Triangle

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstdlib>
    #include <cstring>
    #include <vector>
    #include <cassert>
    #include <string>
    #include <cmath>
    #define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    #define lowbit(x) (x & -x)
    using namespace std;
    typedef long long ll;
    const int MAX = 0x7ffffff;
    int t;
    
    void slove()
    {
    	int a, b , c  ,d;
    	cin >> a >> b >> c >> d;
    	cout << b << " " << c << " " << c << endl;
    }
    int main()
    {
    	SIS;
    	cin >> t;
    	while(t--)
    	{
    		slove();
    	}
    }
    
  • 相关阅读:
    hdu1418 欧拉公式
    hdu1215七夕节 筛选法求公因子和
    hdu1215 The area
    hdu1005Number Sequence
    hdu1021 数学题 并不是说难,而是数学题那种简单朴素的思想get不到
    Mongo第三个参数的用法
    js 显示刚刚上传的图片 (onchange事件)
    在linux中安装memcache服务器
    jQuery 倒计时
    PHP获取文章发布时间
  • 原文地址:https://www.cnblogs.com/wlw-x/p/12757948.html
Copyright © 2011-2022 走看看