zoukankan      html  css  js  c++  java
  • 2021.1.17高一模拟赛题解

    点我下载题目

    T1

    绫濑的作业 | ayase.cpp

    就根据题意慢慢模拟就行了
    只用 if 就能AC的水题
    不过还是有几个坑点的:
    比如负号。
    (mitruha逐渐CCF化)

    #include <bits/stdc++.h>
    using namespace std ;
     
    double x, v1, v2, v3, t;
    char ch1, ch2;
    double level = 0;
    
    int main () 
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    
        freopen("ayase.in", "r", stdin);
        freopen("ayase.out", "w", stdout);
    	
        cin >> x >> v1;
        
        if (x < 0) v1 *= -1;
        level += v1;
        
        cin >> ch1 >> v2;
        
        if (ch1 == 'W') v2 *= -1;
        level += v2;
        
        cin >> ch2 ;
        if (ch2 == 'Y') 
        {
            cin >> ch2 >> v3;
            
            if (ch2 == 'W') v3 *= -1;	
            level += v3;
        }
        
        if (level == 0) 
        {
    	puts("No solution!");
    	exit(0);
        }
    	
        t = x / level;
        
        if (t < 0)
    	puts("No solution!");
        else
    	cout << ceil(t);
        return 0;
    }
    

    T2

    七海的烦恼 | nanami.cpp

    不难想到用DFS做
    先写出把每个灯更新的函数:

    inline void update(int X, int Y)
    {
    	light[X][Y] = 1 - light[X][Y];
    	light[X + 1][Y] = 1 - light[X + 1][Y];
    	light[X - 1][Y] = 1 - light[X - 1][Y];
    	light[X][Y + 1] = 1 - light[X][Y + 1];
    	light[X][Y - 1] = 1 - light[X][Y - 1];
    }
    

    然后把每一个点都搜一遍
    不过要注意剪枝,否则你会喜提TLE
    AC代码:

    #include <bits/stdc++.h>
    using namespace std;
    const int N = 10;
    int Min_ans = 10;
    int light[N][N];
    int ans = 0;
    
    inline int mitru_read()
    {
    	int s = 0, w = 1;
    	char ch = getchar();
    	while(ch < '0' || ch > '9')
    	{
    		if(ch == '-')
    			w = -1;
    		ch = getchar();
    	}
    	while(ch >= '0' && ch <= '9')
    		s = s * 10 + (ch ^ 48), ch = getchar();
    	return s * w; 
    }
    
    inline void update(int X, int Y)
    {
    	light[X][Y] = 1 - light[X][Y];
    	light[X + 1][Y] = 1 - light[X + 1][Y];
    	light[X - 1][Y] = 1 - light[X - 1][Y];
    	light[X][Y + 1] = 1 - light[X][Y + 1];
    	light[X][Y - 1] = 1 - light[X][Y - 1];
    }
    
    inline void dfs(int cnt)
    {
    	if(cnt > Min_ans)
    		return;
    	int tot = 0;
    	for(register int i = 1; i <= 3; i++)
    	{
    		for(register int j = 1; j <= 3; j++)
    		{
    			tot += light[i][j];
    		}
    	}
    	if(tot == 9)
    	{
    		ans = cnt - 1;
    		if(ans < Min_ans)
    			Min_ans = ans;
    	}
    	for(register int i = 1; i <= 3; i++)
    	{
    		for(register int j = 1; j <= 3; j++)
    		{
    			update(i, j);
    			dfs(cnt + 1);
    			update(i, j);
    		}
    	}
    	return;
    }
    
    int main()
    {
    	freopen("nanami.in", "r", stdin);
    	freopen("nanami.out", "w", stdout);
    	
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	
    	for(register int i = 1; i <= 3; i++)
    	{
    		for(register int j = 1; j <= 3; j++)
    		{
    			light[i][j] = mitru_read();
    		}
    	}
    	dfs(1);
    	cout << ans;
    	return 0;
    }
    

    T3

    茉优的房间 | mayu.cpp

    推出来是斐波那契数列
    直接算,都可以算

    #include <bits/stdc++.h>
    using namespace std;
    const int Maxn = 1e4;
    typedef long long ll;
    
    inline int mitru_read()
    {
    	int s = 0, w = 1;
    	char ch = getchar();
    	while(ch < '0' || ch > '9')
    	{
    		if(ch == '-')
    			w = -1;
    		ch = getchar();
    	}
    	while(ch >= '0' && ch <= '9')
    		s = s * 10 + (ch ^ 48), ch = getchar();
    	return s * w; 
    }
    
    int m, n;
    ll f[Maxn];
    
    int main()
    {
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	
    	freopen("mayu.in", "r", stdin);
    	freopen("mayu.out", "w", stdout);
    	
    	m = mitru_read();
    	n = mitru_read();
    	f[1] = 1, f[2] = 2;
    	
    	for(int i = 3; i <= n - m; i++) 
    		f[i] = f[i - 1] + f[i - 2];
    
    	cout << f[n - m];
    	return 0;
    } 
    

    TX
    梦 | yami.cpp
    az
    我不会做

  • 相关阅读:
    github上Devstack的一些变动,截至8.20
    Tokyo Tyrant(TTServer)系列(二)-启动參数和配置
    云方案术语
    四大桌面云显示协议解析
    rdesktop -u qinrui -p 'Aa7788..' 192.168.3.117 -a 32 -g workarea
    IOS开发之block应用
    怎样用EA设计ER图
    使用Jsoup解析和操作HTML
    Speak a Good Word for SB
    LeetCode234_PalindromeLinkedList (推断是否为回文链表) Java题解
  • 原文地址:https://www.cnblogs.com/misaka1932/p/14289357.html
Copyright © 2011-2022 走看看