• 军训场G,H


    G - 年纪大的果子哥

    思路:数学,思维。
    对于购买 h a l f p l u s halfplus halfplus,这种情况,一定是购买了了带小数点的情况,例如1.5,2.5,3.5这种,因为只有这种情况,才会出现赠送半个苹果,设这种情况为 x x x,我们逆推回去,在这种状态没有购买之前的苹果个数为 2 × x + 1 2\times x+1 2×x+1
    对于购买 h a l f half half的情况,那么购买的肯定是整数个,因为不存在赠送,购买后为 x x x,那么逆推回购买前的状态为 2 × x 2\times x 2×x

    #include
    
    using namespace std;
    const int N=4e6+5;
    typedef long long ll;
    typedef pair<ll,ll > pll;
    typedef array<ll,3> p3;
    int mod=998244353;
    const int maxv=4e6+5;
    
    void solve()
    {	
    	int n,p;
    	cin>>n>>p;
    	string s[n+5];
    	for(int i=0;i<n;i++){
    		string a;
    		cin>>a;
    		s[i]=a;
    	}
    	ll tot=0,sum=0;
    	for(int i=n-1;i>=0;i--){
    		if(s[i]=="halfplus"){
    			sum+=tot*p+p/2;
    			tot=tot*2+1;
    		}
    		else {
    			sum+=tot*p;
    			tot*=2;
    		}
    	}
    	cout<<sum<<endl;
    }
    
    int main()
    {
    	ios::sync_with_stdio(0);
    	cin.tie(0);
    	cout.tie(0);
        int t;
    	t=1;
    	//cin>>t;
        while(t--){
            solve();
        }
    	system("pause");
    	return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48

    H - lcf学姐的约会时间

    思路:思维。
    和上一题相比,这题思维更简单,我们对题目进行一个简单的翻译,即求每一行中最小值的最大值。

    #include 
    
    using namespace std;
    const int N = 1e6 + 5;
    typedef long long ll;
    typedef pair<ll, ll> pll;
    typedef array<ll, 3> p3;
    int mod = 998244353;
    const int maxv = 4e6 + 5;
    
    int a[205][205];
    
    void solve()
    {
        int n,m;
        cin>>n>>m;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                cin>>a[i][j];
            }
        }
        int ans=0;
        for(int i=1;i<=n;i++){
            int res=2e9;
            for(int j=1;j<=m;j++) res=min(res,a[i][j]);
            ans=max(ans,res);
        }
        cout<<ans<<endl;
    }
    
    int main()
    {
        ios::sync_with_stdio(0);
        cin.tie(0);
        int t = 1;
      //  cin >> t;
        while (t--)
        {
            solve();
        }
        system("pause");
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
  • 相关阅读:
    react实现路由拦截器
    人脸比对CNN设计
    JS数据类型的探究
    AWS-CDK的实践和应用
    UE5创建C++项目里报错
    List知识总结
    各种表格第三方库
    计算机毕设(附源码)JAVA-SSM基于的校园失物招领平台
    详解GaussDB(DWS)中的行执行引擎
    【漏洞复现】广联达办公OAsql+文件上传+弱口令
  • 原文地址:https://blog.csdn.net/Unlimited_ci/article/details/132890800