东华复试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网络自身内部实现建模 开放词汇翻译的建模 。另外为了除了 让翻译过程更简单,我们发现子词模型在罕见词的翻译上取得了比大型词汇模型和回退词典 更高的准确性,后退词典并且 能够创造性能产地 的生成在训练期间未见过的新词。我们的分析展示了神经网络能够学习来自子词表现出示中 的复合构词 和音译能力
相关推荐
盐焗西兰花21 分钟前
鸿蒙学习实战之路-Share Kit系列(16/17)-隔空传送与可信任设备
学习·华为·harmonyos
少许极端1 小时前
算法奇妙屋(四十二)-贪心算法学习之路 9
学习·算法·贪心算法
EmbeddedCore1 小时前
MQTT协议学习笔记(深入解析版)
笔记·学习
WYT王玉桐3 小时前
LINUX学习
学习
H Journey3 小时前
openCV学习之-腐蚀
人工智能·opencv·学习
AI成长日志3 小时前
【算法学习专栏】动态规划基础·简单三题精讲(70.爬楼梯、118.杨辉三角、121.买卖股票的最佳时机)
学习·算法·动态规划
嵌入式小企鹅3 小时前
阿里编程模型赶超、半导体涨价蔓延、RISC-V新品密集上线
人工智能·学习·ai·程序员·risc-v·芯片
艾莉丝努力练剑4 小时前
【Linux系统:信号】线程安全不等于可重入:深度拆解变量作用域与原子操作
java·linux·运维·服务器·开发语言·c++·学习
red_redemption4 小时前
自由学习记录(155)
学习
菜鸟‍4 小时前
【论文学习】Disco:基于邻接感知协同着色的密集重叠细胞实例分割方法
人工智能·学习·算法