zoukankan      html  css  js  c++  java
  • zlb的8.19考试

    张老板!

    张老板!

    张老板!

    张老板!

    张老板!


    存一下代码8


    #include <iostream>
    #include <stdio.h>
    #include <string.h>
    #include <algorithm>
    #define maxn 35
    using namespace std ;
    int read() {
    	int x = 0 , f = 1 ; char s = getchar() ;
    	while(s > '9' || s < '0') {if(s == '-') f = -1 ; s = getchar() ;}
    	while(s <='9' && s >='0') {x = x * 10 + (s-'0'); s = getchar() ;}
    	return x*f ;
    }
    int n , a[maxn] , ans , tot ;
    int prime[110000] , vis[110000] ;
    void pre() {
    	vis[0] = vis[1] = 1 ;
    	 for(int i = 2 ; i <= 10000 ; ++i )
    	 {
    	 	if(!vis[i]) prime[tot++] = i ;
    	 	for(int j = 0 ; j <= tot && prime[j] * i <= 10000 ; ++j )
    	 	{
    	 		vis[prime[j] * i ] = 1 ;
    	 		if(!(i % prime[j])) break ;
    		 }
    	 }
    }
    int judge(int x) {
    	if(!vis[x]) return 1 ;
    	return 0 ;
    } 
    int main () {
    	n = read() ;
    	pre() ;
    	for(int i = 1 ; i <= n ; i ++) a[i] = read() ;
    	for(int i = 1 ; i <= n ; i ++) {
    		for(int j = i+1 ; j <= n ; j ++) {
    			for(int k = j+1 ; k <= n ; k ++) {
    				if(judge(a[i]+a[j]+a[k])) {
    					//cout << a[i] << " " << a[j] << " " << a[k] <<endl ;
    					ans ++ ;
    				}
    			}
    		}
    	}
    	printf("%d
    ",ans) ;
    	return 0 ;
    } 
    

    
    #include <iostream>
    #include <stdio.h>
    #include <string.h>
    #include <algorithm>
    #define maxn 110000
    using namespace std ;
    int read() {
    	int x = 0 , f = 1 ; char s = getchar() ;
    	while(s > '9' || s < '0') {if(s == '-') f = -1 ; s = getchar() ;}
    	while(s <='9' && s >='0') {x = x * 10 + (s-'0'); s = getchar() ;}
    	return x*f ;
    }
    int n , m ;
    int a[maxn] , s[maxn] ;
    int main () {
    	n = read() , m = read() ;
    	for(int i = 1 ; i <= n ; i ++) {
    		a[i] = read() ;
    		s[i] = s[i-1] + a[i] ;
    	}
    	while(m --) {
    		int l ,r ;
    		l =read() , r = read() ;
    		printf("%d
    ",s[r]-s[l-1]) ;
    	}
    } 
    

    
    #include<iostream>
    #include<stdio.h>
    #include<stack>
    #include<string.h> 
    
    using namespace std;
    
    int num[305] , n ;
    
    char s[305];
    
    stack <int> st;
    
    char S[]={'{','[','(','<','}',']',')','>'};
    
    int main() {
    	scanf("%d",&n) ;
    	for(int k = 1 ; k <= n ; k ++) {
    		scanf("%s",s+1) ;
    		while(!st.empty())
    		st.pop() ;bool flag = 1 ;
    		int len = strlen(s+1) ;
    		
    		for(int i = 1 ; i <= len ; i ++)
    		for(int j = 0 ; j < 8 ; j ++)
    		if(s[i] == S[j]) {
    			num[i] = j ;
    			break ;
    		}
    		for(int i = 1 ; i <= len ; i ++) {
    			if(num[i] <= 3) {
    				if(st.empty() || num[i] >= st.top())
    				st.push(num[i]) ;
    				else {
    					flag = 0;
    					break;
    				}
    			}
    			else {
    				if(!st.empty()&&st.top()+4 == num[i])
    				st.pop() ;
    				else {
    					flag = 0;
    					break;
    				}
    			}
    		}
    		if (!st.empty())
    		puts("NO");
    		else if (flag)
    		puts("YES");
    		else
    		puts("NO");
    	}
    	return 0;
    }
    

    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    #include<cmath>
    using namespace std;
    bool s[2000020];
    int d,t;
    int k=1;
    int main()
    {
    	cin>>d>>t;
    	int n=pow(2,d)-1;
    	for(int i=1;i<=t;i++)
    	{
    		k=1;
    		while(1)
    		{
    			s[k]=!s[k];
    			if(s[k]) k*=2;
    			else k=k*2+1;
    			if(k>n) break;
    		}
    	}
    	printf("%d
    ",k/2);
    	return 0;
    }
    
    

    
    #include<cstdio>
    #include <iostream>
    #include<algorithm>
    using namespace std;
    const int maxn = 100010;
    const int maxm = 99999997;
    struct MyStruct
    {
        int data;
        int loc;
    }a[maxn],b[maxn];
    int e[maxn], n, c[maxn];
    int inline readint()
    {
        int x = 0;
        char c = getchar();
        while (c<'0' || c>'9') c = getchar();
        while (c >= '0'&&c <= '9')
        {
            x = x * 10 + c - '0';
            c = getchar();
        }
        return x;
    }
    int lowbit(int x)
    {
        return x&-x;
    }
    void add(int x,int t)
    {
        while (x <= n)
        {
            e[x] += t;
            e[x] %= maxm;
            x += lowbit(x);
        }
    }
    int sum(int x)
    {
        int s = 0;
        while(x)
        {
            s += e[x];
            s %= maxm;
            x -= lowbit(x);
        }
        return s;
    }
    bool cmp(MyStruct x, MyStruct y)
    {
        return x.data < y.data;
    }
    int A[10] , B[10 ] ;
    int main()
    {
       // n = readint();
        n = 6 ;
        for(int i = 1 ; i <= 6 ; i ++) {
        	char s ;
        	cin >> s ;
        	A[i] = s -'0' ;
        }
        for(int j = 1 ; j <= 6 ; j ++){
        	char s ;
        	cin >> s ;
        	B[j] = s -'0' ;
        }
        for (int i = 1; i <= n; i++)
        {
            a[i].data = A[i];
            a[i].loc = i;
        }
        for (int i = 1; i <= n; i++)
        {
            b[i].data = B[i];
            b[i].loc = i;
        }
        sort(a + 1, a + n + 1, cmp);
        sort(b + 1, b + n + 1, cmp);
        for (int i = 1; i <= n; i++)
        {
            c[a[i].loc] = b[i].loc;
        }
        int ans = 0;
        for (int i = 1; i <= n; i++)
        {
            add(c[i], 1);
            ans += i - sum(c[i]); 
            ans %= maxm;
        }
        printf("%d", ans);
        return 0;
    }
    

    我菜死了!!

  • 相关阅读:
    http delete 服务端拿不到body
    VUE 指定、获取DOM元素的自定义值
    delphi + redis 实现即时消息
    VUE 父组件、子组件图片链接
    【杂记】Linux 学习笔记
    【杂记】Oracle
    iOS 容易造成循环引用的三种场景
    NSNotificationCenter KVO KVC Delegate Block
    C语言和OC的区别? 面向对象和面向过程的区别?
    SDWebImage的实现原理
  • 原文地址:https://www.cnblogs.com/lyt020321/p/11376172.html
Copyright © 2011-2022 走看看