zoukankan      html  css  js  c++  java
  • 每日算法

    每日算法

    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.3.29


    我太菜了 今天开始补cfdiv3

    CF#629Div3 A

    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <cstring>
    
    using namespace std;
    int n;
    int main()
    {
    	cin >> n;
    	int a, b ;
    	while(n --)	
    	{
    		cin >> a >> b;
    		if(a % b == 0)printf("0
    ");
    		else{ 
    			printf("%d
    ",b - (a % b));
    		}
    	}
    	return 0;
    } 
    

    CF#629Div3 B

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<iostream>
    #include<cmath>
     
    using namespace std;
     
    int main()
    {
    	int t, ii, n, k, sum, i, j;
    	scanf("%d", &t);
    	for (ii = 0; ii<t; ii++) 
    	{
    		scanf("%d %d", &n, &k);
    		sum = 0;
    		k--;
    		for (i = 0;; i++)
    		{
    			if (sum + i + 1 > k)
    			{
    				break;
    			}
    			sum += i + 1;
    		}
    		k -= sum;
    		i++;
    		for (j = 0; j<n; j++) 
    		{
    			if (j == n - i - 1 || j == n - k - 1)
    			{
    				printf("b");
    			}
    			else
    			{
    				printf("a");
    			}
    		}
    		printf("
    ");
    	}
    	return 0;
    }
    

    CF#629Div3 C

    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <cstring>
    
    using namespace std;
    
    void func()
    {
    	int n;
    	cin >> n;
    	string s , a , b;
    	cin >> s;
    	int flag = 0;
    	for(int i = 0;i < s.size() ;i ++)
    	{
    		if(s[i] == '2')
    		{
    			if(flag == 0)
    				a+='1',b+='1';
    			else 
    				a+='0',b+='2';	
    		}
    		else if(s[i] == '0')a+='0',b+='0';
    		else{
    			if(flag == 0)
    			{
    				flag = 1;
    				a+='1';b+='0'; 
    			}
    			else{
    				a += '0';b += '1';
    			}
    		}	
    	}
    	cout << a << endl;
    	cout << b << endl;	
    }
    int main()
    {
    	int t;cin >> t;
    	while(t--)
    	{
    		func();	
    	}	
    	return 0;
    } 
    

    摆动序列

    假dp 真搜索

    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <cstring>
    
    using namespace std;
    int n, ans;
    bool vis[25];
    void dfs(int a ,int b)
    {
    	if(b > a){
    		for(int i = 1;i < a ;i ++)
    		{
    			if(!vis[i])
    			{
    				ans++;
    				vis[i] = 1;
    				dfs(b , i);
    				vis[i] = 0;
    			}
    		}
    	}
    	else if(a > b){ 
    		for(int i = a + 1;i <= n;i ++)
    		{
    			if(!vis[i])
    			{	
    				ans++;
    				vis[i] = 1;
    				dfs(b , i);
    				vis[i] = 0;
    			}
    		}
    	}
    }
    int main()
    {
    	cin >> n;
    	for(int i = 1;i <= n ;i ++)
    	{
    		vis[i] = 1;
    		for(int j = 1;j <= n ;j ++)
    		{
    			if(i != j)
    			{
    				ans++;
    				vis[j] = 1;
    				dfs(i , j);
    				vis[j] = 0;
    			}
    		}
    	}
    	cout << ans << endl;
    	return 0;
    }
    
    

    拦截导弹

    (o(n^{2}))

    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    
    using namespace std;
    const int N = 100005;
    int f[N], a[N], n;
    
    int main()
    {
    	while(~scanf("%d",&a[++n]));n--;
    	int ans1 = 0, ans2 = 0;
    	for(int i = n;i >= 1 ;i --)
    	{
    		f[i] = 1;
    		for(int j = i + 1;j <= n ;j ++)
    		{
    			if(a[j] <= a[i])
    				f[i] = max(f[i],f[j] + 1);
    		}
    		ans1 = max(ans1,f[i]);
    	}
    	for(int i = 1;i <= n ;i ++)
    	{
    		f[i] = 1;
    		for(int j = 1;j < i ;j ++)
    		{
    			if(a[j] < a[i])
    				f[i] = max(f[i],f[j] + 1);
    		}
    		ans2 = max(ans2,f[i]);
    	}
    	printf("%d
    %d",ans1,ans2);
    	return 0;
    }
    
  • 相关阅读:
    jMeter 里 CSV Data Set Config Sharing Mode 的含义详解
    如何使用 jMeter Parallel Controller
    使用 Chrome 开发者工具 coverage 功能分析 web 应用的渲染阻止资源的执行分布情况
    使用 Chrome 开发者工具的 lighthouse 功能分析 web 应用的性能问题
    关于 SAP 电商云首页加载时触发的 OCC API 请求
    SAP UI5 确保控件 id 全局唯一的实现方法
    SAP 电商云 Accelerator 和 Spartacus UI 的工作机制差异
    介绍一个好用的能让网页变成黑色背景的护眼 Chrome 扩展应用
    Chrome 开发者工具 performance 标签页的用法
    Client Side Cache 和 Server Side Cache 的区别
  • 原文地址:https://www.cnblogs.com/wlw-x/p/12595469.html
Copyright © 2011-2022 走看看