东华复试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(s1[i]==' ')边界的重置循环计数 len=0;curIndex=-1; 不应在if(len>ansLen)条件判断下。即边界->判断和重置,而非边界->判断->重置
  • 盲区2:边界条件仅设置在s1[i]==' ',未考虑末尾无空格,故对仅一个单词为一行或末尾单词丢失判断。
  • 题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网络自身内部实现建模 开放词汇翻译的建模 。另外为了除了 让翻译过程更简单,我们发现子词模型在罕见词的翻译上取得了比大型词汇模型和回退词典 更高的准确性,后退词典并且 能够创造性能产地 的生成在训练期间未见过的新词。我们的分析展示了神经网络能够学习来自子词表现出示中 的复合构词 和音译能力
相关推荐
盐水冰2 小时前
【Redis】学习(2)Redis常见命令
数据库·redis·学习
adore.9682 小时前
3.13 复试学习
学习
SteveSenna2 小时前
机械臂模仿学习2.3:生成式对抗模仿学习GAIL
学习
科技林总3 小时前
【系统分析师】11.5 软件需求文档化
学习
python零基础入门小白3 小时前
多智能体强化学习:从基础到实战,掌握协作与竞争的艺术!
人工智能·学习·chatgpt·大模型·产品经理·ai大模型·大模型学习
arvin_xiaoting4 小时前
从 0 到 1:搭建自学习 AI Agent 系统的完整工程指南
人工智能·学习·系统设计·ai agent·lancedb·自学习·openclaw
飞Link4 小时前
深度解析 TS2Vec:时序表示学习中的层次化建模(Hierarchical Contrastive Learning)
开发语言·python·学习·数据挖掘
格鸰爱童话4 小时前
向AI学习项目技能(二)
java·人工智能·python·学习