noi-2026年4月07号作业

张开发
2026/4/9 18:27:28 15 分钟阅读
noi-2026年4月07号作业
题目P1009 [NOIP 1998 普及组] 阶乘之和网址https://www.luogu.com.cn/problem/P1009思路高精度加法和乘法知识点高精度代码:#includebits/stdc.h #define ull unsigned long long #define ll long long #define pll pairll,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 maxn1e6100; const ll mode21e97; int vis[maxn]; string str; ll a[maxn]; ll n,m; vectorint get_fac(int x) { vectorintv(1000,0); v[0]1; for(int i2;ix;i) { for(int j0;j1000;j) v[j]*i; int jw0; for(int j0;j1000;j) { v[j]jw; jwv[j]/10; v[j]%10; } } return v; } void solve() { vectorintans(1000,0); cinn; for(int i1;in;i) { vectorint vget_fac(i); for(int j0;j1000;j) ans[j]v[j]; } int jw0; for(int i0;i1000;i) { ans[i]jw; jwans[i]/10; ans[i]%10; } int pos1000-1; while(pos1ans[pos]0) pos--; for(int ipos;i0;i--) coutans[i]; } int main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int T1; // cinT; while(T--) solve(); return 0; }题目P1042 [NOIP 2003 普及组] 乒乓球网址https://www.luogu.com.cn/problem/P1042思路结束的两个条件1.必须有个人的得分大于等于11/21分2.两个人的分差大于等于2.知识点模拟题代码:#includebits/stdc.h #define ull unsigned long long #define ll long long #define pll pairll,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 maxn1e6100; const ll mode21e97; int vis[maxn]; string str; ll a[maxn]; ll n,m; void solve() { str; while(true) { string s; cins; bool okfalse; for(int i0;is.length();i) { if(s[i]E) { oktrue; break; } strs[i]; } if(ok) break; } int lenstr.length(); int W0,L0; for(int i0;ilen;i) { if(str[i]W) W; else L; if(max(W,L)11abs(W-L)2) { coutW:L\n; W0;L0; } } coutW:L\n; cout\n; W0; L0; for(int i0;ilen;i) { if(str[i]W) W; else L; if(max(W,L)21abs(W-L)2) { coutW:L\n; W0;L0; } } coutW:L\n; } int main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int T1; // cinT; while(T--) solve(); return 0; }题目P2670 [NOIP 2015 普及组] 扫雷游戏网址https://www.luogu.com.cn/problem/P2670思路主要是定义好两个方向数组dx和dy。知识点模拟题代码:#includebits/stdc.h #define ull unsigned long long #define ll long long #define pll pairll,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 maxn1e6100; const ll mode21e97; 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 cnt0; for(int i0;i7;i) { int xxxdx[i],yyydy[i]; if(xx0xxnyy0yym) { if(str[xx][yy]*) cnt; } } return cnt; } void solve() { cinnm; for(int i0;in;i) { cinstr[i]; } for(int i0;in;i) { for(int j0;jm;j) { if(str[i][j]?) { int cntcal(i,j); str[i][j]0cnt; } } } for(int i0;in;i) { coutstr[i]\n; } } int main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int T1; // cinT; while(T--) solve(); return 0; }题目P1563 [NOIP 2016 提高组] 玩具谜题网址https://www.luogu.com.cn/problem/P1563思路我们按照题目的意思就行模拟不要忘记进行取模操作知识点模拟代码:#includebits/stdc.h #define ull unsigned long long #define ll long long #define pll pairll,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 maxn1e6100; const ll mode21e97; int vis[maxn]; string str; ll a[maxn]; ll n,m; int front[maxn]; string name[maxn]; void solve() { cinnm; for(int i0;in;i) { cinfront[i]name[i]; } int now0; while(m--) { int op,cnt; cinopcnt; if(front[now]0)//nei { if(op0)//zuo { now-cnt; now(now%nn)%n; }else{//you nowcnt; now(now%nn)%n; } }else{//wai if(op0)//zuo { nowcnt; now(now%nn)%n; }else{//you now-cnt; now(now%nn)%n; } } } coutname[now]; } int main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int T1; // cinT; while(T--) solve(); return 0; }

更多文章