#include<iostream>usingnamespace std;intmain(){// 请在此输入您的代码int dx[4]={0,1,1,-1};int dy[4]={1,-1,0,1};int r =1, c =1, t =1, d =0;while(r !=20|| c !=20){if(d ==0){
r = r + dx[d];
c = c + dy[d];
t ++;}elseif(d ==1){while(c >=2){
r = r + dx[d];
c = c + dy[d];
t ++;if(r ==20&& c ==20){
cout << t << endl;return0;}}}elseif(d ==2){
r = r + dx[d];
c = c + dy[d];
t ++;}else{while(r >=2){
r = r + dx[d];
c = c + dy[d];
t ++;if(r ==20&& c ==20){
cout << t << endl;return0;}}}
d =(d +1)%4;}return0;}
七段码
#include<iostream>#include<cstring>#include<algorithm>usingnamespace std;constint N =10;int n;int g[N][N];bool st[N];voiddfs(int t,int u){
st[u]=true;for(int j =0; j <7; j ++)if(g[u][j +1]&&(t >> j &1)&&!st[j +1])dfs(t, j +1);}boolcheck(int x){int t = x, cnt =0;memset(st,0,sizeof st);for(int j =0; j <7; j ++)if(t >> j &1&&!st[j +1]){dfs(t, j +1);
cnt ++;}return cnt ==1;}intmain(){for(int i =1; i <=6; i ++){
g[i][i +1]= g[i +1][i]=1;}
g[2][7]= g[7][2]=1;
g[3][7]= g[7][3]=1;
g[5][7]= g[7][5]=1;
g[1][6]= g[6][1]=1;int ans =0;for(int i =1; i <(1<<7); i +=1){if(check(i)) ans ++;}
cout << ans << endl;return0;}
B组
直线
#include<iostream>#include<cstring>#include<algorithm>#include<cmath>usingnamespace std;constint N =200000;int n;structLine{double k, b;booloperator<(const Line& t)const{if(k != t.k)return k < t.k;return b < t.b;}}l[N];intmain(){for(int x1 =0; x1 <20; x1 ++)for(int y1 =0; y1 <21; y1 ++)for(int x2 =0; x2 <20; x2 ++)for(int y2 =0; y2 <21; y2 ++)if(x1 != x2){double k =(double)(y2 - y1)/(x2 - x1);double b = y1 - k * x1;
l[n ++]={k, b};}sort(l, l + n);int res =1;for(int i =1; i < n; i ++)if(fabs(l[i].k - l[i -1].k)>1e-8||fabs(l[i].b - l[i -1].b)>1e-8)
res ++;
cout << res +20<< endl;return0;}
货物摆放
#include<iostream>#include<cstring>#include<algorithm>#include<vector>usingnamespace std;typedeflonglong LL;intmain(){
LL n;
cin >> n;
vector<LL> d;for(LL i =1; i * i <= n; i ++)if(n % i ==0){
d.push_back(i);if(n / i != i) d.push_back(n / i);}int res =0;for(auto a: d)for(auto b: d)for(auto c: d)if(a * b * c == n)
res ++;
cout << res << endl;return0;}