零点工作室暑假集训(AtCoder--ABC233)

A - 10yen Stamp

题意:
Takahashi想要给圣诞老人寄一封信。他的信封上贴着一张面值为X日元的邮票。
为了能够被送到圣诞老人那里,这个信封上的邮票的总面值必须至少为Y日元。
Takahashi将会再贴一些面值为10日元的邮票,以使得整个信封上的邮票的总面值至少为Y日元。
Takahashi至少需要再贴多少张10日元的邮票到这个信封上?

思路: 向上取余即可

AC代码

#include<bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"
#define xx first
#define yy second
#define sz size

typedef long long LL;
typedef pair<int , int> PII;
typedef pair<LL , LL> PLL;
 
const int N = 110, INF = 0x3f3f3f3f, Mod = 1e9 + 7;

int n;
int x[N], y[N];

void solved()
{
	int x, y;
	cin >> x >> y;
	if(x < y)
	{
		if((y - x) % 10)//有余数需要多补一
		{
			cout << (y - x) / 10 + 1 << endl;
		} 
		else 
		{
			cout << (y - x) / 10 << endl;
		}
	} 
	else 
	{
		cout<<0<<endl;
	}
	
    return ;
    
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t = 1;
    //int t;
    //cin >> t;
 
    while(t -- )
    {
        solved();
    }
 
    return 0;
}

B - A Reverse

题意: 给定整数L、R和一个由小写英文字母组成的字符串S,打印将S中第L个到第R个字符(包括L和R)反转顺序后的字符串。

思路: 正常的模拟,计算每个点的度数,判断是否有一个点的度数为N - 1 即可

AC代码

#include<bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"
#define xx first
#define yy second
#define sz size

typedef long long LL;
typedef pair<int , int> PII;
typedef pair<LL , LL> PLL;
 
const int N = 110, INF = 0x3f3f3f3f, Mod = 1e9 + 7;


void solved()
{
	int n, m;
	cin >> n >> m;
	m = m - n + 1;//区间长度
	n --;
	string s, t;
	cin >> s;
	t = s.substr(n, m);//区间内的部分
	
	reverse(t.begin(),t.end());
	
	cout << s.substr(0, n) << t << s.substr(m + n) << endl;
	
    return ;
    
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t = 1;
    //int t;
    //cin >> t;
 
    while(t -- )
    {
        solved();
    }
 
    return 0;
}

C - Produc

题意: 我们有N个袋子。
第i个袋子中包含Li个球。第i个袋子中的第j个球(1≤j≤Li)上写着正整数ai,j。
我们将从每个袋子中挑出一个球来。
有多少种方式可以挑选这些球,使得挑选出的球上写的数字的乘积为X?

思路: 使用了行列可变的二维vector数组,深搜从第一行往最后一行搜即可。dfs(u, sum)第一个参数表示第几行,第二个参数表示乘积。剪枝:当乘积为0或大于X时直接退出。记得开long long

#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>

using namespace std;

typedef long long LL;

vector<vector<int>> a;

LL n;
LL x;
int res = 0;

void dfs(int u, LL sum)
{
	if (u == n)
	{
		if (sum == x) res ++;
		return;
	}
	for (int i = 0; i < a[u].size(); i ++)
	{
		if (sum > x / a[u][i]) continue;
		dfs(u + 1, sum * a[u][i]);
	}
}

int main()
{
    cin >> n >> x;
    for (int i = 0; i < n; i ++)
    {
    	vector<int> t;
    	int k;
    	cin >> k;
    	for (int j = 1; j <= k; j ++)
    	{
    		int p;
    		cin >> p;
    		t.push_back(p);
		}
		a.push_back(t);
	}
	
	dfs(0, 1);
	
    cout << res << endl;
    
    return 0;
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值