东华复试OJ二刷复盘7

 进阶7:不妨设An=sin(1+sin(2-sin(3+sin(4-...sin(n))...)、Sn=(...(A1+n)A2+n-1)A3+...+2)An+1

 请你帮助FJ打印出Sn的完整表达式。

cpp 复制代码
#include <bits/stdc++.h>
using namespace std;

void An(int n){
	for(int i=1;i<=n;i++){
		cout<<"sin("<<i;
		if(i!=n){
			if(i%2==1)cout<<'+';
			else cout<<'-';
		}
		else{
			for(int i=1;i<=n;i++){
				cout<<')';
			}
		}
	}
	return ;
}

void Sn(int n,int max){
	for(int i=1;i<=max-1;i++)cout<<'(';
	for(int i=1;i<=max;i++){
		//if(i==1)cout<<'(';
		An(i);
		cout<<'+'<<n-(i-1);
		if(n-(i-1)!=1)cout<<')';
	}
}

int main(){
	int n;
	cin>>n;
	Sn(n,n);
	cout<<endl;
//	while(cin>>n){
//		An(n,n);
//		cout<<endl;
//	}
	
	
	system("pause");
}

题82:输入一个十进制数,将其化成N进制数输出(2≤N≤16)。 输出结果时,大于等于10的数字用字母代替,A代表10,B代表11以此类推。

cpp 复制代码
if(target==10)cout<<n<<endl;continue;
if(target==10||n==0){
			cout<<n<<endl;continue;
		}
  • 语句不合逻辑,必须要用大括号框住两句,否则是if 限定执行第一句,然后默认执行第二句。
  • WA为输入范例为0,尝试后猜出

题84:从键盘输入一个字符串和一个字符,将输入字符从字符串中删除,输出新的字符串。如果字符串中没有此字符,则原样输出字符串。

cpp 复制代码
getline(cin,s1);
char ch1;  ch1 = cin.get();
  • 字符串匹配指定字符:存在指定字符为空格的情况
  • getline(cin,s1)会回收本行空格使下次输入正常接收。
  • ch1 = cin.get() 读取单个字符包括空白字符。

题95:在一行英文单词中,找出其中最长的单词(若有多个最长,找出第一个出现的),并输出这个单词的长度。

cpp 复制代码
#include <bits/stdc++.h>
using namespace std;

int main(){
	string s1;
	while(getline(cin,s1)){
		int ansLen=0;int ansIndex=-1;
		int len=0;int curIndex=-1;
		for(int i=0;i<s1.size();i++){
			if(s1[i]==' '){
				if(len>ansLen){
					ansLen=len;ansIndex=curIndex;
				}
				len=0;curIndex=-1;
			}
			else{len++;
				if(curIndex==-1)curIndex=i;
			} 
		}
		if(curIndex!=-1){
			if(len>ansLen){
				ansLen=len;ansIndex=curIndex;
			}
		}
		cout<<ansLen<<' ';
		for(int i=ansIndex,j=0;j<ansLen;i++,j++){
			cout<<s1[i];
		}
		cout<<endl;
	}
}
  • 盲区1:if(s1i==' ')边界的重置循环计数 len=0;curIndex=-1; 不应在if(len>ansLen)条件判断下。即边界->判断和重置,而非边界->判断->重置
  • 盲区2:边界条件仅设置在s1i==' ',未考虑末尾无空格,故对仅一个单词为一行或末尾单词丢失判断。
  • 题98:加法器5+111同理

We investigate NMT models that operate on the level of subword units. Our main goal is to model open-vocabulary translation in the NMT network itself, without requiring a back-off model for rare words. In addition to making the translation process simpler, we also find that the subword models achieve better accuracy for the translation of rare words than large-vocabulary models and back-off dictionaries, and are able to productively generate newwords that were not seen at training time. Our analysis shows that the neural networks are able to learn compounding and transliteration from sub word representations.

  • 我们探索了运行在子词单元层面上 的NMT模型。我们的主要目标是在不需要依赖 用于罕见词的后退模型的情况下,对NMT网络自身内部实现建模 开放词汇翻译的建模 。另外为了除了 让翻译过程更简单,我们发现子词模型在罕见词的翻译上取得了比大型词汇模型和回退词典 更高的准确性,后退词典并且 能够创造性能产地 的生成在训练期间未见过的新词。我们的分析展示了神经网络能够学习来自子词表现出示中 的复合构词 和音译能力
相关推荐
通信小呆呆10 天前
当算法有了“五感”:多模态数据融合如何向人体感官协同学习?
人工智能·学习·算法·机器学习·机器人
H__Rick10 天前
自动对焦学习-3
人工智能·学习·计算机视觉
Daisy Lee10 天前
量化学习-第1章-什么是量化金融
学习·金融·datawhale
Alsn8610 天前
等待学习-学习目录:Docker 容器安全攻防
学习·安全·docker
YM52e10 天前
买菜计算器小应用 - HarmonyOS ArkUI 开发实战-PC版本
学习·华为·harmonyos·鸿蒙·鸿蒙系统
小雨下雨的雨10 天前
HarmonyOS ArkUI训练营入门-组件掌握系列-Animation 动画效果实现-PC版本
学习·华为·harmonyos·鸿蒙
cqbzcsq10 天前
CellFlow虚拟细胞论文阅读
论文阅读·人工智能·笔记·学习·生物信息
YangYang9YangYan10 天前
2026初入职场学习数据分析的价值
学习·数据挖掘·数据分析
guslegend10 天前
理论学习:什么是 Coding Agent?
学习
自传.10 天前
尚硅谷 Vibe Coding|第三章(1) Claude Code深度使用与进阶技巧 学习笔记
笔记·学习·尚硅谷·vibecoding