news 2026/5/11 14:20:38

noi-2026年4月07号作业

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
noi-2026年4月07号作业

题目:P1009 [NOIP 1998 普及组] 阶乘之和

网址:https://www.luogu.com.cn/problem/P1009

思路:高精度加法和乘法

知识点:高精度

代码:

#include<bits/stdc++.h> #define ull unsigned long long #define ll long long #define pll pair<ll,ll> #define fi first #define cer2(a,b) cerr<<#a<<'='<<(a)<<','<<#b<<'='<<(b)<<"@ line"<<__LINE__<<endl #define se second #define db double #define eb emplace_back #define pb push_back using namespace std; const int maxn=1e6+100; const ll mode2=1e9+7; int vis[maxn]; string str; ll a[maxn]; ll n,m; vector<int> get_fac(int x) { vector<int>v(1000,0); v[0]=1; for(int i=2;i<=x;i++) { for(int j=0;j<1000;j++) v[j]*=i; int jw=0; for(int j=0;j<1000;j++) { v[j]+=jw; jw=v[j]/10; v[j]%=10; } } return v; } void solve() { vector<int>ans(1000,0); cin>>n; for(int i=1;i<=n;i++) { vector<int> v=get_fac(i); for(int j=0;j<1000;j++) ans[j]+=v[j]; } int jw=0; for(int i=0;i<1000;i++) { ans[i]+=jw; jw=ans[i]/10; ans[i]%=10; } int pos=1000-1; while(pos>=1&&ans[pos]==0) pos--; for(int i=pos;i>=0;i--) cout<<ans[i]; } int main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int T=1; // cin>>T; while(T--) solve(); return 0; }

题目:P1042 [NOIP 2003 普及组] 乒乓球

网址:https://www.luogu.com.cn/problem/P1042

思路:结束的两个条件:1.必须有个人的得分大于等于11/21分;2.两个人的分差大于等于2.

知识点:模拟题

代码:

#include<bits/stdc++.h> #define ull unsigned long long #define ll long long #define pll pair<ll,ll> #define fi first #define cer2(a,b) cerr<<#a<<'='<<(a)<<','<<#b<<'='<<(b)<<"@ line"<<__LINE__<<endl #define se second #define db double #define eb emplace_back #define pb push_back using namespace std; const int maxn=1e6+100; const ll mode2=1e9+7; int vis[maxn]; string str; ll a[maxn]; ll n,m; void solve() { str=""; while(true) { string s; cin>>s; bool ok=false; for(int i=0;i<s.length();i++) { if(s[i]=='E') { ok=true; break; } str+=s[i]; } if(ok) break; } int len=str.length(); int W=0,L=0; for(int i=0;i<len;i++) { if(str[i]=='W') W++; else L++; if(max(W,L)>=11&&abs(W-L)>=2) { cout<<W<<":"<<L<<'\n'; W=0;L=0; } } cout<<W<<":"<<L<<'\n'; cout<<'\n'; W=0; L=0; for(int i=0;i<len;i++) { if(str[i]=='W') W++; else L++; if(max(W,L)>=21&&abs(W-L)>=2) { cout<<W<<":"<<L<<'\n'; W=0;L=0; } } cout<<W<<":"<<L<<'\n'; } int main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int T=1; // cin>>T; while(T--) solve(); return 0; }

题目:P2670 [NOIP 2015 普及组] 扫雷游戏

网址:https://www.luogu.com.cn/problem/P2670

思路:主要是定义好两个方向数组,dx和dy。

知识点:模拟题

代码:

#include<bits/stdc++.h> #define ull unsigned long long #define ll long long #define pll pair<ll,ll> #define fi first #define cer2(a,b) cerr<<#a<<'='<<(a)<<','<<#b<<'='<<(b)<<"@ line"<<__LINE__<<endl #define se second #define db double #define eb emplace_back #define pb push_back using namespace std; const int maxn=1e6+100; const ll mode2=1e9+7; int vis[maxn]; string str[110]; ll a[maxn]; ll n,m; int dx[]={-1,-1,-1,0,0,1,1,1}; int dy[]={-1,0,1,-1,1,-1,0,1}; int cal(int x,int y) { int cnt=0; for(int i=0;i<=7;i++) { int xx=x+dx[i],yy=y+dy[i]; if(xx>=0&&xx<n&&yy>=0&&yy<m) { if(str[xx][yy]=='*') cnt++; } } return cnt; } void solve() { cin>>n>>m; for(int i=0;i<n;i++) { cin>>str[i]; } for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { if(str[i][j]=='?') { int cnt=cal(i,j); str[i][j]='0'+cnt; } } } for(int i=0;i<n;i++) { cout<<str[i]<<'\n'; } } int main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int T=1; // cin>>T; while(T--) solve(); return 0; }

题目:P1563 [NOIP 2016 提高组] 玩具谜题

网址:https://www.luogu.com.cn/problem/P1563

思路:我们按照题目的意思就行模拟,不要忘记进行取模操作

知识点:模拟

代码:

#include<bits/stdc++.h> #define ull unsigned long long #define ll long long #define pll pair<ll,ll> #define fi first #define cer2(a,b) cerr<<#a<<'='<<(a)<<','<<#b<<'='<<(b)<<"@ line"<<__LINE__<<endl #define se second #define db double #define eb emplace_back #define pb push_back using namespace std; const int maxn=1e6+100; const ll mode2=1e9+7; int vis[maxn]; string str; ll a[maxn]; ll n,m; int front[maxn]; string name[maxn]; void solve() { cin>>n>>m; for(int i=0;i<n;i++) { cin>>front[i]>>name[i]; } int now=0; while(m--) { int op,cnt; cin>>op>>cnt; if(front[now]==0)//nei { if(op==0)//zuo { now-=cnt; now=(now%n+n)%n; }else{//you now+=cnt; now=(now%n+n)%n; } }else{//wai if(op==0)//zuo { now+=cnt; now=(now%n+n)%n; }else{//you now-=cnt; now=(now%n+n)%n; } } } cout<<name[now]; } int main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int T=1; // cin>>T; while(T--) solve(); return 0; }
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/5/11 14:20:15

Presente 是干嘛的?

所有业务逻辑都在 Presenter 里,它知道: 什么时候该开始 什么时候该停止 循环怎么跑 测完了要做什么 MainTestSettingPresenter 这个类是来干嘛的?这个类是老师?指挥? The user is asking about the role of MainTestSettingPresenter in the MVP architecture. Let me ex…

作者头像 李华
网站建设 2026/4/9 18:23:58

解锁智能散热:开源工具FanControl的多场景风扇管理指南

解锁智能散热&#xff1a;开源工具FanControl的多场景风扇管理指南 【免费下载链接】FanControl.Releases This is the release repository for Fan Control, a highly customizable fan controlling software for Windows. 项目地址: https://gitcode.com/GitHub_Trending/f…

作者头像 李华
网站建设 2026/5/11 14:16:59

归并排序力扣题(leetcode)刳

1.概述在人工智能快速发展的今天&#xff0c;AI不再仅仅是回答问题的聊天机器人&#xff0c;而是正在演变为能够主动完成复杂任务的智能代理。OpenAI的Codex CLI就是这一趋势的典型代表——一个跨平台的本地软件代理&#xff0c;能够在用户的机器上安全高效地生成高质量的软件变…

作者头像 李华
网站建设 2026/4/9 18:22:54

历时半年,开源了一套企业级 Agentic RAG 系统!

为什么学习 AI 项目 AI 这波浪潮&#xff0c;Java 程序员已经躲不过去了。 不管你现在做的是业务系统还是中间件&#xff0c;面试的时候多多少少都会被问到 AI 相关的东西。RAG 是什么&#xff1f;Agent 怎么实现&#xff1f;用过 MCP 吗&#xff1f;这些问题越来越高频。可以…

作者头像 李华
网站建设 2026/4/9 18:22:25

量子机器学习:传统AI的颠覆者?

测试工程师的技术十字路口当量子计算以叠加态、纠缠态等特性突破经典计算边界时&#xff0c;其与人工智能融合催生的量子机器学习&#xff08;QML&#xff09; 正引发软件测试领域的范式变革。本文将从测试验证逻辑、工具链演进及质量保障体系三方面&#xff0c;剖析QML对传统A…

作者头像 李华
网站建设 2026/4/9 18:18:38

如何用Awoo Installer实现Switch全格式游戏安装的无缝体验

如何用Awoo Installer实现Switch全格式游戏安装的无缝体验 【免费下载链接】Awoo-Installer A No-Bullshit NSP, NSZ, XCI, and XCZ Installer for Nintendo Switch 项目地址: https://gitcode.com/gh_mirrors/aw/Awoo-Installer 对于Nintendo Switch玩家而言&#xff0…

作者头像 李华