版本比较
4.27 总结
正文
增加 16 行删除 16 行
9 行未改动1011121314141516171819202122232422232425262728293031323334343536373820 行未改动596061626364636465666768686970717220 行未改动9394959697979899991001011021033 行未改动10710810911011111111211311411511611711611711811912012112212212312412512632 行未改动15916016116216316316416516616716716816917017115 行未改动9 行未改动的值,保留两位小数。## Solution按题意来做,从顶层开始一直向下递归,没啥好说的。
Teacher.J 说这也是送分题,但我没做出来,小数递归写着写着写乱了。 Teacher.J 说这也是送分题,但我没做出来,小数递归写着写着写乱了。## Code```cpp#include <bits/stdc++.h>using namespace std;#define int long longdouble ans[10005];double dfs(double x,int st) { if(st == 0) return 1;//递归结束 if(ans[st] != -1) return ans[st];//算过就不再算了 ans[st] = st * 1.0 / (st + dfs(st - 1));//计算这一层的值 if(st == 0) return 1;//递归结束 if(ans[st] != -1) return ans[st];//算过就不再算了 ans[st] = st * 1.0 / (st + dfs(st - 1));//计算这一层的值 return ans[st];}signed main() { int n; double t,x; cin >> t >> x; for(int i = 1;i <= 10000;i ++) { ans[i] = -1; } while(t --) {//多组数据 while(t --) {//多组数据 cin >> n; double anss = dfs(x,n); printf("%.2lf\n",anss); }20 行未改动const int Mod = 1e9 + 7;int n,a,b,c;map<int,int>mp;int dfs(int st) { if(mp.count(st)) return mp[st];//找过的不再找一次 if(st <= c) return 1;//Game over if(mp.count(st)) return mp[st];//找过的不再找一次 if(st <= c) return 1;//Game over int res1 = dfs(st - a) % Mod; int res2 = dfs(st - b) % Mod; return mp[st] = (res1 + res2) % Mod;//我合着写就挂了,玄学? //记忆化 //记忆化}signed main() { cin >> n >> a >> b >> c; cout << dfs(n) % Mod;20 行未改动int dfs(int x,int y) { if(dp[x][y] != -1) return dp[x][y]; for(int d = 0;d < 4;d ++) { int px = x + dx[d],py = y + dy[d]; if(px < 1 || px > r || py < 1 || py > c) continue; //越界 if(px < 1 || px > r || py < 1 || py > c) continue; //越界 if(high[px][py] < high[x][y]) {//是不是比当前位置小 dp[x][y] = max(dp[x][y],dfs(px,py) + 1); //神秘的转移 dp[x][y] = max(dp[x][y],dfs(px,py) + 1); //神秘的转移 } } return dp[x][y];}3 行未改动 for(int j = 1;j <= c;j ++) { cin >> high[i][j]; } } for(int i = 1;i <= r;i ++) {//初始化 for(int i = 1;i <= r;i ++) {//初始化 for(int j = 1;j <= c;j ++) { dp[i][j] = -1; } } int ans = -91917891;//恶趣味 for(int i = 1;i <= r;i ++) {//找答案 int ans = -91917891;//恶趣味 for(int i = 1;i <= r;i ++) {//找答案 for(int j = 1;j <= c;j ++) { ans = max(ans,dfs(i,j)); } } cout << ans + 2;//没算起点和终点 cout << ans + 2;//没算起点和终点}```
# P5635 【CSGRound1】天下第一32 行未改动 cin >> x >> y; int f = 1,i = 1; mp.clear(); while(f == 1) { if(mp.count({x,y})) {//判平局 if(mp.count({x,y})) {//判平局 cout << "error" << endl; f = 0; } if(i % 2 == 1) { // 奇数回合,代表本回合对x进行改变 if(i % 2 == 1) { // 奇数回合,代表本回合对x进行改变 mp[{x,y}] = 1; x = (x + y) % p; if(x == 0) { cout << 1 << endl;15 行未改动