Good Bye 2023(A被hack,状态不好)

文章讲述了在Codeforces竞赛中遇到的三个编程问题:求解最小公倍数的变种、通过博弈模拟优化结果以及处理奇偶性问题。涉及的算法包括模拟和数学计算。

A.输出一堆1,然后输出2023/ans,ans*=b[i];得开LL(暴躁)

// Problem: A. 2023
// Contest: Codeforces - Good Bye 2023
// URL: https://codeforces.com/contest/1916/problem/0
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//へ     /|
//  /\7    ∠_/
//  / │   / /
// │ Z _,< /   /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │ //
//  / へ   / ノ<| \\
//  ヽ_ノ  (_/  │//
//	  7       |/
//	  >―r ̄ ̄`ー―_
#include <iostream>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
ll a[N],b[N];
void solve() {
	ll n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>b[i];
	}
	ll ans=1;
	for(int i=1;i<=n;i++){
		ans*=b[i];
	}
	if(2023%ans==0){
		cout<<"YES"<<'\n';
		for(ll i=1;i<=k-1;i++){
			cout<<1<<" ";
		}
		cout<<2023/ans<<'\n';
		return;
	}else{
		cout<<"NO"<<'\n';
	}
}
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int q;
	cin >> q;
	while (q--) {
		solve();
	}

	return 0;
}

B.一眼看可能是最小公倍数,但是1,5,是25,因此把每个例子带一遍就知道是什么了.

ans*=b/a;

// Problem: B. Two Divisors
// Contest: Codeforces - Good Bye 2023
// URL: https://codeforces.com/contest/1916/problem/B
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//へ     /|
//  /\7    ∠_/
//  / │   / /
// │ Z _,< /   /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │ //
//  / へ   / ノ<| \\
//  ヽ_ノ  (_/  │//
//	  7       |/
//	  >―r ̄ ̄`ー―_
#include <iostream>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N];
ll gcd(ll a, ll b){
	return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
void solve() {
	ll a,b;
	cin>>a>>b;
	ll ans=lcm(a,b);
	if(ans==b){
		ans*=b/a;
	}
	cout<<ans<<'\n';
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int q;
	cin >> q;
	while (q--) {
		solve();
	}

	return 0;
}

C.博弈得模拟,找到怎么变成最小值,怎么变成最大值,发现损失就在奇数和偶数.模拟一下过程可以发现,奇数+奇数=偶数,就可以没有损失,但是如果有3个奇数就可以发现,肯定会损失(-1),每3次(-1),如果还%3==1(也就是最后是奇数+偶数)(肯定会损失).

// Problem: C. Training Before the Olympiad
// Contest: Codeforces - Good Bye 2023
// URL: https://codeforces.com/contest/1916/problem/C
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//へ     /|
//  /\7    ∠_/
//  / │   / /
// │ Z _,< /   /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │ //
//  / へ   / ノ<| \\
//  ヽ_ノ  (_/  │//
//	  7       |/
//	  >―r ̄ ̄`ー―_
#include <iostream>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
ll a[N];
void solve() {
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	ll sum=0;
	ll cnt=0;
	for(int i=1;i<=n;i++){
		sum+=a[i];
		if(a[i]&1){
			cnt++;
		}
		if(i==1){
			cout<<a[i]<<" ";
			continue;
		}
		ll del=cnt/3;
		if(cnt%3==1){
			del++;
		}
		cout<<sum-del<<" ";	
	}
	cout<<'\n';
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int q;
	cin >> q;
	while (q--) {
		solve();
	}

	return 0;
}

解析到 21 行歌词 2025-12-04 18:16:58.492 31580-31580 LrcDebug com.weishitech.qichechangtingyinyue D [00:01.00]歌曲名 背叛 [00:02.00]歌手名 曹格 [00:03.00]作词:阿丹/邬裕康 [00:04.00]作曲:曹格 [00:14.06]雨 [00:16.01]不停落下来 [00:21.30]花 [00:23.09]怎么都不开 [00:27.82]尽管我细心灌溉 [00:31.46]你说不爱就不爱 [00:35.12]我一个人 [00:39.11]欣赏悲哀 [00:43.10]爱 [00:45.15]只剩下无奈 [00:50.43]我 [00:52.18]一直不愿再去猜 [00:56.97]钢琴上黑键之间 [01:00.51]永远都夹着空白 [01:04.25]缺了一块 [01:08.14]就不精彩 [01:12.33]紧紧相依的心如何 [01:16.03]Say goodbye [01:19.47]你比我清楚还要我说明白 [01:25.90]爱太深会让人疯狂的勇敢 [01:33.79]我用背叛自己 [01:37.33]完成你的期盼 [01:41.07]把手放开不问一句 [01:44.61]Say goodbye [01:48.05]当作最后一次对你的溺爱 [01:54.49]冷冷清清淡淡今后都不管 [02:02.32]只要你能愉快 [02:18.61]心 [02:20.15]有一句感慨 [02:25.74]我 [02:27.54]还能够跟谁对白 [02:32.62]在你关上门之前 [02:35.72]替我再回头看看 [02:39.61]那些片段 [02:43.30]还在不在 [02:47.29]紧紧相依的心如何 [02:50.88]Say goodbye [02:54.47]你比我清楚还要我说明白 [03:00.76]爱太深会让人疯狂的勇敢 [03:08.44]我用背叛自己 [03:12.28]完成你的期盼 [03:15.98]把手放开不问一句 [03:19.47]Say goodbye [03:23.11]当作最后一次对你的溺爱 [03:29.44]冷冷清清淡淡今后都不管 [03:37.18]只要你能愉快 [04:02.51]紧紧相依的心如何 [04:06.35]Say goodbye [04:09.70]你比我清楚还要我说明白 [04:16.03]爱太深会让人疯狂的勇敢 [04:23.57]我用背叛自己 [04:27.31]完成你的期盼 [04:31.45]把手放开不问一句 [04:34.79]Say goodbye [04:38.38]当作最后一次对你的溺爱 [04:44.62]冷冷清清淡淡今后都不管 [04:52.75]只要你能愉快 [05:03.03]只要你能愉快 package com.weishitech.qichechangtingyinyue.fragment.Adapter; import android.content.Context; import android.graphics.Color; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.hfd.common.util.DensityUtil; import com.hw.lrcviewlib.LrcDataBuilder; import com.hw.lrcviewlib.LrcRow; import com.hw.lrcviewlib.LrcView; import com.weishitech.qichechangtingyinyue.R; import com.weishitech.qichechangtingyinyue.bean.MusicBean; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; // SongPagerAdapter.java public class SongPagerAdapter extends RecyclerView.Adapter<SongPagerAdapter.SongViewHolder> { List<LrcRow> lrcRows; private final List<MusicBean.DataBean> data; private final Context context; private int currentPosition = 0; // 播放回调接口 public interface OnPageSelectedListener { void onPageSelected(int position, MusicBean.DataBean song); } private OnPageSelectedListener listener; public void setOnPageSelectedListener(OnPageSelectedListener l) { this.listener = l; } public SongPagerAdapter(Context context, List<MusicBean.DataBean> data) { this.context = context; this.data = new ArrayList<>(data); } @NonNull @Override public SongViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view = LayoutInflater.from(context).inflate(R.layout.fragment_song_item, parent, false); return new SongViewHolder(view); } @Override public void onBindViewHolder(@NonNull SongViewHolder holder, int position) { MusicBean.DataBean song = data.get(position); holder.tvTitle.setText(song.getTitle()); holder.tvSinger.setText(song.getSinger()); Glide.with(context) .load(song.getCover()) .into(holder.ivCover); String lrcText = song.getLrc(); Log.d("LrcDebug", ""+lrcText); lrcRows = new LrcDataBuilder().builtFromText(lrcText); Log.d("LrcDebug", "解析到 " + (lrcRows != null ? lrcRows.size() : "null") + " 行歌词"); holder.lyricView.getLrcSetting() .setTimeTextSize(40)//时间字体大小 .setSelectLineColor(Color.parseColor("#FFFFFF"))//选中线颜色 .setSelectLineTextSize(25)//选中线大小 .setNormalRowColor(Color.parseColor("#919191")) .setHeightRowColor(Color.parseColor("#FFFFFF"))//高亮字体颜色 .setNormalRowTextSize(DensityUtil.sp2px(context, 17))//正常行字体大小 .setHeightLightRowTextSize(DensityUtil.sp2px(context, 17))//高亮行字体大小 .setTrySelectRowTextSize(DensityUtil.sp2px(context, 17))//尝试选中行字体大小 .setTimeTextColor(Color.parseColor("#FFFFFF"))//时间字体颜色 .setTrySelectRowColor(Color.parseColor("#FFFFFF"));//尝试选中字体颜色 holder.lyricView.commitLrcSettings(); holder.lyricView.setLrcData(lrcRows); // 标记当前绑定位置 holder.itemView.setTag(position); } @Override public int getItemCount() { return data.size(); } static class SongViewHolder extends RecyclerView.ViewHolder { ImageView ivCover; TextView tvTitle, tvSinger; LrcView lyricView; public SongViewHolder(@NonNull View itemView) { super(itemView); ivCover = itemView.findViewById(R.id.iv_cover); tvTitle = itemView.findViewById(R.id.tv_title); tvSinger = itemView.findViewById(R.id.tv_singer); lyricView = itemView.findViewById(R.id.lyricView); } } public MusicBean.DataBean getCurrentSong(int position) { if (position >= 0 && position < data.size()) { return data.get(position); } return null; } public class LrcDataBuilder { public List<LrcRow> builtFromText(String lrcText) { List<LrcRow> rows = new ArrayList<>(); if (lrcText == null || lrcText.trim().isEmpty()) { return rows; } String[] lines = lrcText.split("\\r?\\n"); for (String line : lines) { List<LrcRow> parsed = parseLrcLine(line.trim()); if (!parsed.isEmpty()) { rows.addAll(parsed); } } Collections.sort(rows); // 按时间排序 return rows; } private List<LrcRow> parseLrcLine(String line) { List<LrcRow> result = new ArrayList<>(); // 匹配所有 [mm:ss.xxx] 类型的时间标签 Pattern pattern = Pattern.compile("\\[(\\d{1,3}):(\\d{2})(?:\\.(\\d{2,3}))?\\]"); Matcher matcher = pattern.matcher(line); if (!matcher.find()) { // 没有时间标签,视为无效行或元数据(如 [ti:歌名]),可跳过 return result; } // 回退 matcher 到开头重新遍历 matcher.reset(); while (matcher.find()) { String originalTimeTag = matcher.group(0); // 完整标签 "[mm:ss.xx]" int min = Integer.parseInt(matcher.group(1)); int sec = Integer.parseInt(matcher.group(2)); int milli = 0; if (matcher.group(3) != null) { milli = Integer.parseInt(matcher.group(3)); if (matcher.group(3).length() == 2) { milli *= 10; // 将 xx 转为 xxx 毫秒 } } long timeMillis = (min * 60L + sec) * 1000 + milli; // 找到第一个时间标签之后的内容作为歌词正文 int textStart = line.lastIndexOf(']') + 1; // 取最后一个 ] 之后的内容 String text = line.substring(textStart).trim(); // 构造 LrcRow 对象(三参数构造器) result.add(new LrcRow(originalTimeTag, text, timeMillis)); } return result; } } } 打印是有歌词的,但是没显示
12-05
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值