东华复试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网络自身内部实现建模 开放词汇翻译的建模 。另外为了除了 让翻译过程更简单,我们发现子词模型在罕见词的翻译上取得了比大型词汇模型和回退词典 更高的准确性,后退词典并且 能够创造性能产地 的生成在训练期间未见过的新词。我们的分析展示了神经网络能够学习来自子词表现出示中 的复合构词 和音译能力
相关推荐
是隼人8 小时前
buuctf-pwn xdctf2015_pwn200题解(学习过程持续更新)
c语言·学习·安全·pwn入门·ctf入门
大衛說9 小时前
《Python 从入门到精通》系列总览与学习路线
开发语言·python·学习
吃好睡好便好10 小时前
查找函数的使用
学习·算法·matlab·生活·查找函数
学运维的Kysan10 小时前
暑假运维学习打卡第二十九天8.29
学习
zbyyd11 小时前
Linux 进程间通信学习笔记
linux·笔记·学习
一条破秋裤11 小时前
02_软件安装与新建工程
学习
来了就未晚11 小时前
Python基础 学习代码存储与命名规范
开发语言·python·学习
GHL28427109011 小时前
用codex做一个简单技能学习
学习·ai
西西弗Sisyphus12 小时前
模型训练 不同批次大小与学习率下的训练损失对比(2)
学习·batchsize·lr·learning rate
软件开发技术深度爱好者13 小时前
在线学习实践 TypeScript 的官方Playground(演练场)使用介绍
javascript·学习·typescript