CF1467(Round 695 div2)题解

CF1467A

显然:

  • n n n 1 1 1 时答案为 9 9 9
  • n n n 2 2 2 时答案为 98 98 98
  • n n n 3 3 3 时答案为 989 989 989

n > 3 n>3 n>3 时,假设我们在第 x x x 秒选择让第 i i i 个位置暂停,如果 i > 2 i>2 i>2 i = 1 i=1 i=1,那么最终得到的答案的前三位一定比 989 989 989 要小。因此当 n > 3 n>3 n>3 时最优方案就是 n = 3 n=3 n=3 时的方案:在第 8 8 8 秒时暂停第 2 2 2 个位置。

代码如下:

/*
 
_/      _/    _/_/_/      _/_/_/    _/_/_/_/_/    _/_/_/    _/_/_/_/    _/      _/  _/      _/  _/      _/
_/      _/  _/      _/  _/      _/      _/      _/      _/  _/      _/  _/      _/   _/    _/    _/    _/
_/      _/  _/      _/  _/              _/      _/      _/  _/      _/  _/      _/    _/  _/      _/  _/
_/      _/  _/_/_/_/_/  _/              _/      _/      _/  _/_/_/_/    _/  _/  _/      _/         _/_/
  _/  _/    _/          _/              _/      _/      _/  _/  _/      _/  _/  _/      _/        _/  _/
   _/_/     _/      _/  _/      _/      _/      _/      _/  _/    _/     _/_/_/_/       _/       _/    _/
    _/        _/_/_/      _/_/_/        _/        _/_/_/    _/      _/    _/  _/        _/      _/      _/
 
*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
#define fo(i,x,y) for(register int i=x;i<=y;++i)
#define go(i,x,y) for(register int i=x;i>=y;--i)
using namespace std;

inline int read(){
	int x=0,fh=1;
	char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*fh;
}

string s="989";

void work(){
	int n=read();
	if(n<=3){
		cout<<s.substr(0,n)<<endl;
		return; 
	}
	cout<<s;
	fo(i,0,n-4) printf("%d",i%10);
	puts("");
}
int main(){
	int T=read();
	while(T--){
		work();
	}
	return 0;
}

CF1467B

考虑将某个位置变成哪些值是可能产生贡献的。由于 a i a_{i} ai 的变化为影响三个位置: a i − 1 , a i , a i + 1 a_{i-1},a_{i},a_{i+1} ai1,ai,ai+1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
抱歉,根据提供的引用内容,我无法理解你具体想要问什么问题。请提供更清晰明确的问题,我将竭诚为你解答。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Codeforces Round 860 (Div. 2)题解](https://blog.csdn.net/qq_60653991/article/details/129802687)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [【Codeforces】 Codeforces Round 865 (Div. 2) (补赛)](https://blog.csdn.net/t_mod/article/details/130104033)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [Codeforces Round 872 (Div. 2)(前三道](https://blog.csdn.net/qq_68286180/article/details/130570952)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值