zoukankan      html  css  js  c++  java
  • Educational Codeforces Round 90 (Rated for Div. 2) A~C

    直接判断单价和单买就可以


    #include<bits/stdc++.h>
    #include<string.h>
    using namespace std;
    #define rep(i,j,k) for(LL i=(j); i<(k); ++i)
    #define pb push_back
    #define PII pair<LL,LL>
    #define PLL pair<long long, long long>
    #define ini(a,j) memset(a,j,sizeof a)
    #define rrep(i,j,k) for(LL i=j; i>=k; --i)
    #define fi first
    #define se second
    #define LL long long
    #define beg begin()
    #define ed end()
    #define all(x) x.begin(),x.end()
    
    
    int main(int argc, char const *argv[])
    {
    	// #define DEBUG
        	#ifdef DEBUG
    		freopen("1.dat","r",stdin);
    		freopen("ans.dat","w",stdout);
    	#endif
    	LL _;
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	cout.tie(0);
    	cin>>_;
    	while(_--){
    		LL a,b,c;
    		cin>>a>>b>>c;
    		LL ans1=-1;
    		LL ans2=-1;
    		if(a<c)
    			ans1 = 1;
    		if(a*b>c)
    			ans2 = b;
    		cout<<ans1<<" "<<ans2<<endl;
    	}
    	return 0;
    }
    

    仔细思考会发现,少的那个总会被消除完的,因为不可能使得两个都有剩下而不相邻

    #include<bits/stdc++.h>
    #include<string.h>
    using namespace std;
    #define rep(i,j,k) for(LL i=(j); i<(k); ++i)
    #define pb push_back
    #define PII pair<LL,LL>
    #define PLL pair<long long, long long>
    #define ini(a,j) memset(a,j,sizeof a)
    #define rrep(i,j,k) for(LL i=j; i>=k; --i)
    #define fi first
    #define se second
    #define LL long long
    #define beg begin()
    #define ed end()
    #define all(x) x.begin(),x.end()
    
    // const int N = 1e5+10;
    // int a[N];
    
    int main(int argc, char const *argv[])
    {
    	// #define DEBUG
        	#ifdef DEBUG
    		freopen("1.dat","r",stdin);
    		freopen("ans.dat","w",stdout);
    	#endif
    	LL _;
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	cout.tie(0);
    	cin>>_;
    	while(_--){
    		// 少的那个总是可以消除完的
    		string s;
    		cin>>s;
    		int c = count(all(s),'0');
    		int c2 = s.length()-c;
    		c = min(c, c2);
    		if(c&1)
    			cout<<"DA"<<endl;
    		else
    			cout<<"NET"<<endl;
    
    	}
    	return 0;
    }
    

    记录一波前缀和,每次向后找更小的负数,记录到答案的cnt里就可以


    #include<bits/stdc++.h>
    #include<string.h>
    using namespace std;
    #define rep(i,j,k) for(LL i=(j); i<(k); ++i)
    #define pb push_back
    #define PII pair<LL,LL>
    #define PLL pair<long long, long long>
    #define ini(a,j) memset(a,j,sizeof a)
    #define rrep(i,j,k) for(LL i=j; i>=k; --i)
    #define fi first
    #define se second
    #define LL long long
    #define beg begin()
    #define ed end()
    #define all(x) x.begin(),x.end()
    
    const int N = 1e6+10;
    int a[N];
    
    int main(int argc, char const *argv[])
    {
    	// #define DEBUG
        	#ifdef DEBUG
    		freopen("1.dat","r",stdin);
    		freopen("ans.dat","w",stdout);
    	#endif
    	LL _;
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	cout.tie(0);
    	cin>>_;
    	while(_--){
    		string s;
    		cin>>s;
    		a[0]=0;
    		rep(i,1,s.length()+1)
    			if(s[i-1]=='+')
    				a[i]=a[i-1]+1;
    			else
    				a[i] =a[i-1]-1;
    		// 遇到的每一个负数,都是要进去一次的
    		LL ma = 0;
    		LL ans = 0;
    		LL used = 0;
    		rep(i,1,s.length()+1){
    			if(a[i]>=0)
    				continue;
    			if(a[i]<ma){
    				ans += i*(abs(a[i])-used);
    				used = abs(a[i]);  // 用了a[i]次
    				ma = a[i];
    				// cout<<a[i]<<" "<<i<<endl;
    			}
    		}
    
    		ans += s.length();
    		cout<<ans<<endl;
    	}
    	return 0;
    }
    
  • 相关阅读:
    C++中的private/protected/public
    volatile关键字和mutable关键字
    vector容器使用和assert断言关键字
    静态变量static和extern外引用
    VS开发入门常识
    电子钱包的消费——java card开发第五篇
    电子钱包的圈存——java card开发第四篇
    PPT2010制作图片玻璃磨砂效果
    Word2010制作个人名片
    Word2010制作自动目录
  • 原文地址:https://www.cnblogs.com/Crossea/p/13193913.html
Copyright © 2011-2022 走看看