【无标题】

1.双击

#include<bits/stdc++.h>
using namespace std;
 
int main() {
	int n, d;
	cin >> n >> d;
 
	int p = -1, t = 0;
	for(int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		if(p != -1) {
			if(x - p <= d) {
				if(!t) {
					cout << x << "\n";
				}
			   t = 1;
			}
		}
		p = x;
	}
	if(!t)
	  cout << -1 << '\n';
	return 0;
}

2.chess960

#include<bits/stdc++.h>
using namespace std;
 
int main() {
	string s;
	cin >> s;
	int b = 0, r = 0, t = 1;
	for(int i = 0; i < int(s.size()); i++) {
		if(s[i] == 'R') r ++;
		else if(s[i] == 'B') b += i;
 
		if(s[i] == 'K') {
			if(r == 2 || r == 0) {
				t = 0;
			}
		}
	}
	if(!t || b % 2 == 0) {
		cout << "No\n";
	} else {
		cout << "Yes\n";
	}
 
	return 0;
}

3.

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m,t = 1;
    while (t--){
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        for (int i = 1; i < m; i++)
        {
            if (s[i] == 'T' && s[i - 1] == 'T')
            {
                s[i] = 'C';
                s[i - 1] = 'P';
            }
        }
        cout << s << endl;
    }
    }
    return 0;
}

4. Count Subtractions Editorial

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ll a, b;
    cin >> a >> b;
    ll ans=0;
    while(a>0 && b>0){
        if(a>b){
            ans+=a/b;
            a%=b;
        }
        else{
            ans+=b/a;
            b%=a;
        }
    }
    
    cout << ans-1 << endl;
}

 

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll a[15];
int main(void)
{
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
 
    set<ll> que;//默认的std::less<T>规则,会对存储的 string 类型元素做升序排序
 
    que.insert(0);
 
    int cnt = 0;
    ll ans = 0;
    while (!que.empty())
    {
        ll money = *que.begin();
        que.erase(money);
        for (int i = 0; i < n; i++)
        {
            que.insert(money + a[i]);
        }
 
        if (cnt == k)
        {
            ans = money;
            break;
        }
        cnt++;
    }
 
    cout << ans << endl;
 
    return 0;
}

 

 

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+5; 
 
LL n, m, k, l, r;
LL a[N], cnt, sum;
 
set<LL> st;
 
int main(){
	cin>>n>>l>>r;
	int cnt=0, res=0;
	int x=l+r;
	int s=0;
	for(int i=0; i<n; ++i){
		cin>>k;
		k%=l+r;
		s^=k/l;
	}
	
	if(s)
	   cout<<"First";
	else
	   cout<<"Second";
	
	
	
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值