东华复试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网络自身内部实现建模 开放词汇翻译的建模 。另外为了除了 让翻译过程更简单,我们发现子词模型在罕见词的翻译上取得了比大型词汇模型和回退词典 更高的准确性,后退词典并且 能够创造性能产地 的生成在训练期间未见过的新词。我们的分析展示了神经网络能够学习来自子词表现出示中 的复合构词 和音译能力
相关推荐
今天AI了吗1 小时前
Hermes Agent 搭建全流程:从本机试跑到可持续运行的个人 AI Agent
java·人工智能·python·学习·embedding
一只小菜鸡..1 小时前
Stanford CS144 学习笔记 (二):传输层与数据通信机制
网络·笔记·学习
天选之子1232 小时前
tabulate学习
学习
子非鱼94272 小时前
06-Flutter 鸿蒙实战 06:上传后处理流程,照片识别、故事生成和状态刷新
学习·flutter·华为·harmonyos
天天爱吃肉82183 小时前
# 商用车多体动力学整车仿真学习笔记(开篇总览)
人工智能·笔记·python·功能测试·学习·汽车
xd1855785553 小时前
藏头诗工坊-基于鸿蒙的AI藏头诗创作应用开发实践
人工智能·学习·华为·harmonyos·鸿蒙
一起努力啊~3 小时前
DataWhale组队学习笔记--llm-algo-leetcode(三)
笔记·学习·llm
云空4 小时前
《Three.js 可操控3D魔方(键盘转动+打乱+复原)》
javascript·学习·游戏·3d·three.js
kdxiaojie4 小时前
Linux 驱动研究 —— V4L2 (3)
linux·运维·笔记·学习
十月的皮皮5 小时前
C语言学习笔记20260717-预处理机制
c语言·笔记·学习