<>A 美丽的2

代码:
#include<iostream> #include<cstring> #include<algorithm> #include<cstdio>
#include<cmath> #include<queue> #include<vector> using namespace std; #define
ll long longint int k(int a) { int sum=0; while(a) { int k=a%10; if(k==2) {
return 1; } a/=10; } } int main() { int sum=0; for(int i=2;i<=2020;i++) { sum+=k
(i); } cout<<sum<<endl; return 0; } //563
<>B 扩散

代码:
#include<cstring> #include<algorithm> #include<cstdio> #include<cmath> #define
mp make_pair #include<queue> #include<vector> #include<map> using namespace
std; #define ll long long int a[10005][10005],vis[10005][10005];//表示是否被搜过 int
d[4][2]={0,1,1,0,0,-1,-1,0}; //方向,四联通 ll ans=0; //总值 struct point{
//xy坐标值,t为时间多少秒 int x,y,t; }; void bfs() //广搜 { queue<point> q; //队列 point z,s;
//俩点 z.x=0,z.y=0,z.t=0;q.push(z); //入队 z.x=2020,z.y=11,z.t=0;q.push(z);
z.x=11,z.y=14,z.t=0;q.push(z); z.x=2000,z.y=2000,z.t=0;q.push(z);
vis[0][0]=vis[2020][11]=vis[11][14]=vis[2000][2000]=1; //标记
while(!q.empty())//如果队列不为空 { z=q.front();//z=队头 q.pop();//出队 for(int
i=0;i<4;i++)//四联通图 { s.x=z.x+d[i][0];//+ s.y=z.y+d[i][1]; s.t=z.t+1;//秒数是上一回的+1
if(vis[s.x][s.y]==0&&s.t<=2020)//如果没搜过且不大于2020秒 { vis[s.x][s.y]=1;//标记搜过了
ans++;//总值++ q.push(s);//入队 } } } cout<<ans+4<<endl;//加上本来的四个点 } int main() {
bfs();//广搜 return 0; } //20312088
<>C 阶乘约数

代码:
#include<iostream> #include<cstring> #include<algorithm> #include<cstdio>
#include<cmath> #include<queue> #include<vector> using namespace std; #define
ll long long int flag[105]; int main() { int i; for (int i = 2; i <= 100; i++) {
int tmp = i; for (int j = 2; j <= tmp; j++) { while (tmp % j == 0) { tmp /= j;
flag[j]++; } } } ll ans = 1; for (int i = 1; i <= 100; i++) { ans *= flag[i] + 1
; } cout << ans; } //39001250856960000
<>D 本质上升序列

代码:
#include<iostream> #include<cstring> #include<algorithm> #include<cstdio>
#include<cmath> #define mp make_pair #include<queue> #include<vector>
#include<map> using namespace std; #define ll long long map<string, int> vis;
int main() { queue<pair<string, int> > q; string s; cin >> s; int i; ll ans = 0;
for(i = 0; i < s.size(); i++) { string tmp = ""; tmp += s[i]; if (!vis[tmp]) {
vis[tmp] = 1; q.push(mp(tmp, i)); ans++; } } while (q.size()) { string t = q.
front().first; int pos = q.front().second; q.pop(); for (int i = pos + 1; i < s.
size(); i++) { if (s[i] > s[pos] && !vis[t + s[i]]) { vis[t + s[i]] = 1; q.push(
mp(t + s[i], i)); ans++; } } } cout << ans; } //3616159
<>E 玩具蛇

代码:
#include<iostream> #include<cstring> #include<algorithm> #include<cstdio>
#include<cmath> #define mp make_pair #include<queue> #include<vector>
#include<map> using namespace std; #define ll long long int vis[5][5]; int
nexti[4][2] = { {0,1},{1,0},{0,-1},{-1,0} }; ll ans = 0; void dfs(int x, int
y,int count) { if (x >= 4 || x < 0 || y >= 4 || y < 0)return; if (count == 16) {
ans++; } for (int i = 0; i < 4; i++) { int nx = x + nexti[i][0]; int ny = y +
nexti[i][1]; if (!vis[nx][ny]) { vis[nx][ny] = 1; dfs(nx, ny, count + 1);
vis[nx][ny] = 0; } } } int main() { int i; for (i = 0; i < 4; i++) { for (int j
= 0; j < 4; j++) { vis[i][j] = 1; dfs(i, j, 1); vis[i][j] = 0; } } cout << ans;
} //552 一题优秀,三题锅三,六题国一

技术
下载桌面版
GitHub
Gitee
SourceForge
百度网盘(提取码:draw)
云服务器优惠
华为云优惠券
腾讯云优惠券
阿里云优惠券
Vultr优惠券
站点信息
问题反馈
邮箱:[email protected]
吐槽一下
QQ群:766591547
关注微信