2025寒假天梯训练7
7-8 古风排版 - 2025寒假天梯赛训练7(22 23届)
思路:pta风格模拟题。
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define sz(x) (int)x.size()
#define e emplace_back
//void solve(){
// cout<<"Hello World"<<endl<<"Hello New World";
//}
//void solve(){
// int a,b;
// cin>>a>>b;
// cout<<a*b;
//}
//void solve(){
// double a,b; cin>>a>>b;
// if(b==0) cout<<a<<"/"<<b<<"=Error";
// else{
// cout<<a<<"/";
// if(b<0) cout<<"("<<b<<")";
// else cout<<b;
// cout<<"="<<fixed<<setprecision(2)<<a/b;
// }
//}
//void solve(){
// cout<<fixed<<setprecision(2);
// int n; cin>>n;
// for(int i=1;i<=n;i++){
// char sex; cin>>sex;
// double tall; cin>>tall;
// if(sex=='M') cout<<tall/1.09<<endl;
// if(sex=='F') cout<<tall*1.09<<endl;
// }
//}
//bool check(int year,int n){
// unordered_set<int> st;
// if(year<1000) st.insert(0);
// while(year){
// st.insert(year%10);
// year/=10;
// }
// return n==sz(st);
//}
//void solve(){
// int n;
// string year; cin>>year>>n;
// for(int i=stoi(year);;i++){
// if(check(i,n)){
// cout<<i-stoi(year)<<" ";
// if(i<10) cout<<"000";
// else if(i<100) cout<<"00";
// else if(i<1000) cout<<"0";
// cout<<i;
// break;
// }
// }
//}
//void solve(){
// string A,B;
// string str;
// int cnt=0;
// while(true){
// cin>>str;
// if(str==".") break;
// cnt++;
// if(cnt==2) A=str;
// if(cnt==14) B=str;
// }
// if(cnt>=14) cout<<A+" and "<<B<<" are inviting you to dinner...";
// else if(cnt>=2) cout<<A+" is the only one for you...";
// else cout<<"Momo... No one is for you ...";
//}
//void solve(){
// int n; cin>>n;
// map<int,int> mp;
// for(int i=1;i<=n;i++){
// int k; cin>>k;
// for(int j=1;j<=k;j++){
// int x; cin>>x;
// mp[x]++;
// }
// }
// int num=0,cnt=0;
// for(auto [x,y]:mp){
// if(y>cnt) cnt=y,num=x;
// if(y==cnt) num=max(num,x);
// }
// cout<<num<<" "<<cnt;
//}
char c[105][1005];
void solve(){
int n; cin>>n; // 是每一列的字符数,即行数为n
string str;
cin.ignore();
getline(cin,str);
// cout<<str;
int len=sz(str);
int col=len/n;
if(len%n!=0) col++;
// cout<<col;
for(int i=0;i<n;i++) for(int j=0;j<col;j++) c[i][j]=' ';
for(int i=0;i<n;i++){
for(int j=i,cnt=1;j<sz(str)&&cnt<=col;j+=n,cnt++){
int lie=col-cnt;
c[i][lie]=str[j];
}
}
for(int i=0;i<n;i++){
for(int j=0;j<col;j++){
cout<<c[i][j];
}
cout<<endl;
}
}
int32_t main() {
ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
int t=1;
// cin>>t;
while(t--){
solve();
}
return 0;
}
7-12 功夫传人 - 2025寒假天梯赛训练7(22 23届)
思路:把树dfs一次即可。
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define sz(x) (int)x.size()
#define e emplace_back
//void solve(){
// cout<<"Hello World"<<endl<<"Hello New World";
//}
//void solve(){
// int a,b;
// cin>>a>>b;
// cout<<a*b;
//}
//void solve(){
// double a,b; cin>>a>>b;
// if(b==0) cout<<a<<"/"<<b<<"=Error";
// else{
// cout<<a<<"/";
// if(b<0) cout<<"("<<b<<")";
// else cout<<b;
// cout<<"="<<fixed<<setprecision(2)<<a/b;
// }
//}
//void solve(){
// cout<<fixed<<setprecision(2);
// int n; cin>>n;
// for(int i=1;i<=n;i++){
// char sex; cin>>sex;
// double tall; cin>>tall;
// if(sex=='M') cout<<tall/1.09<<endl;
// if(sex=='F') cout<<tall*1.09<<endl;
// }
//}
//bool check(int year,int n){
// unordered_set<int> st;
// if(year<1000) st.insert(0);
// while(year){
// st.insert(year%10);
// year/=10;
// }
// return n==sz(st);
//}
//void solve(){
// int n;
// string year; cin>>year>>n;
// for(int i=stoi(year);;i++){
// if(check(i,n)){
// cout<<i-stoi(year)<<" ";
// if(i<10) cout<<"000";
// else if(i<100) cout<<"00";
// else if(i<1000) cout<<"0";
// cout<<i;
// break;
// }
// }
//}
//void solve(){
// string A,B;
// string str;
// int cnt=0;
// while(true){
// cin>>str;
// if(str==".") break;
// cnt++;
// if(cnt==2) A=str;
// if(cnt==14) B=str;
// }
// if(cnt>=14) cout<<A+" and "<<B<<" are inviting you to dinner...";
// else if(cnt>=2) cout<<A+" is the only one for you...";
// else cout<<"Momo... No one is for you ...";
//}
//void solve(){
// int n; cin>>n;
// map<int,int> mp;
// for(int i=1;i<=n;i++){
// int k; cin>>k;
// for(int j=1;j<=k;j++){
// int x; cin>>x;
// mp[x]++;
// }
// }
// int num=0,cnt=0;
// for(auto [x,y]:mp){
// if(y>cnt) cnt=y,num=x;
// if(y==cnt) num=max(num,x);
// }
// cout<<num<<" "<<cnt;
//}
//char c[105][1005];
//void solve(){ // 有点点恶心的,,7-8 古风排版--20分
// int n; cin>>n; // 是每一列的字符数,即行数为n
// string str;
// cin.ignore();
// getline(cin,str);
cout<<str;
// int len=sz(str);
// int col=len/n;
// if(len%n!=0) col++;
cout<<col;
// for(int i=0;i<n;i++) for(int j=0;j<col;j++) c[i][j]=' ';
// for(int i=0;i<n;i++){
// for(int j=i,cnt=1;j<sz(str)&&cnt<=col;j+=n,cnt++){
// int lie=col-cnt;
// c[i][lie]=str[j];
// }
// }
// for(int i=0;i<n;i++){
// for(int j=0;j<col;j++){
// cout<<c[i][j];
// }
// cout<<endl;
// }
//}
//void solve(){
// int n; cin>>n;
// int arr[100005];
// for(int i=1;i<=n;i++) cin>>arr[i];
// sort(arr+1,arr+n+1);
// if(n%2==0){
// cout<<"Outgoing #: "<<n/2<<endl;
// cout<<"Introverted #: "<<n/2<<endl;
// cout<<"Diff = ";
// int sumO=0,sumI=0;
// for(int i=1;i<=n;i++){
// if(i<=n/2) sumI+=arr[i];
// else sumO+=arr[i];
// }
// cout<<sumO-sumI;
// }
// else{
// cout<<"Outgoing #: "<<n/2+1<<endl;
// cout<<"Introverted #: "<<n/2<<endl;
// cout<<"Diff = ";
// int sumO=0,sumI=0;
// for(int i=1;i<=n;i++){
// if(i<=n/2) sumI+=arr[i];
// else sumO+=arr[i];
// }
// cout<<sumO-sumI;
// }
//}
//void solve(){
// int n; cin>>n;
// unordered_map<string,bool> follow;
// for(int i=1;i<=n;i++){
// string str; cin>>str;
// follow[str]=true;
// }
// int m; cin>>m;
// int tot=0;
// unordered_map<string,int> like;
// for(int i=1;i<=m;i++){
// string user; cin>>user;
// int num; cin>>num;
// like[user]=num;
// tot+=num;
// }
// vector<string> maybe;
// for(auto [user,num]:like){
// if(num>tot/m&&!follow[user]) maybe.e(user);
// }
// if(sz(maybe)==0) cout<<"Bing Mei You";
// else{
// sort(maybe.begin(),maybe.end());
// for(auto mb:maybe) cout<<mb<<endl;
// }
//}
int n;
double z,r,ans;
vector<int> vct[100005];
map<int,int> good;
void dfs(int u,double power){
if(good[u]!=0){
ans+=good[u]*power;
return;
}
for(auto v:vct[u]) dfs(v,power*(100-r)/100);
}
void solve(){
cin>>n>>z>>r;
for(int i=0;i<=n-1;i++){
int k; cin>>k;
if(k==0){
int x; cin>>x;
good[i]=x;
}
else for(int j=1;j<=k;j++){
int x; cin>>x;
vct[i].e(x);
}
}
dfs(0,z);
cout<<(int)ans; // 只保留整数部分,不四舍五入
}
int32_t main() {
ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
int t=1;
// cin>>t;
while(t--){
solve();
}
return 0;
}
7-13 非常弹的球 - 2025寒假天梯赛训练7(22 23届)
思路:简单的物理题,30分。
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define sz(x) (int)x.size()
#define e emplace_back
//void solve(){
// cout<<"Hello World"<<endl<<"Hello New World";
//}
//void solve(){
// int a,b;
// cin>>a>>b;
// cout<<a*b;
//}
//void solve(){
// double a,b; cin>>a>>b;
// if(b==0) cout<<a<<"/"<<b<<"=Error";
// else{
// cout<<a<<"/";
// if(b<0) cout<<"("<<b<<")";
// else cout<<b;
// cout<<"="<<fixed<<setprecision(2)<<a/b;
// }
//}
//void solve(){
// cout<<fixed<<setprecision(2);
// int n; cin>>n;
// for(int i=1;i<=n;i++){
// char sex; cin>>sex;
// double tall; cin>>tall;
// if(sex=='M') cout<<tall/1.09<<endl;
// if(sex=='F') cout<<tall*1.09<<endl;
// }
//}
//bool check(int year,int n){
// unordered_set<int> st;
// if(year<1000) st.insert(0);
// while(year){
// st.insert(year%10);
// year/=10;
// }
// return n==sz(st);
//}
//void solve(){
// int n;
// string year; cin>>year>>n;
// for(int i=stoi(year);;i++){
// if(check(i,n)){
// cout<<i-stoi(year)<<" ";
// if(i<10) cout<<"000";
// else if(i<100) cout<<"00";
// else if(i<1000) cout<<"0";
// cout<<i;
// break;
// }
// }
//}
//void solve(){
// string A,B;
// string str;
// int cnt=0;
// while(true){
// cin>>str;
// if(str==".") break;
// cnt++;
// if(cnt==2) A=str;
// if(cnt==14) B=str;
// }
// if(cnt>=14) cout<<A+" and "<<B<<" are inviting you to dinner...";
// else if(cnt>=2) cout<<A+" is the only one for you...";
// else cout<<"Momo... No one is for you ...";
//}
//void solve(){
// int n; cin>>n;
// map<int,int> mp;
// for(int i=1;i<=n;i++){
// int k; cin>>k;
// for(int j=1;j<=k;j++){
// int x; cin>>x;
// mp[x]++;
// }
// }
// int num=0,cnt=0;
// for(auto [x,y]:mp){
// if(y>cnt) cnt=y,num=x;
// if(y==cnt) num=max(num,x);
// }
// cout<<num<<" "<<cnt;
//}
//char c[105][1005];
//void solve(){ // 有点点恶心的,,7-8 古风排版--20分
// int n; cin>>n; // 是每一列的字符数,即行数为n
// string str;
// cin.ignore();
// getline(cin,str);
cout<<str;
// int len=sz(str);
// int col=len/n;
// if(len%n!=0) col++;
cout<<col;
// for(int i=0;i<n;i++) for(int j=0;j<col;j++) c[i][j]=' ';
// for(int i=0;i<n;i++){
// for(int j=i,cnt=1;j<sz(str)&&cnt<=col;j+=n,cnt++){
// int lie=col-cnt;
// c[i][lie]=str[j];
// }
// }
// for(int i=0;i<n;i++){
// for(int j=0;j<col;j++){
// cout<<c[i][j];
// }
// cout<<endl;
// }
//}
//void solve(){
// int n; cin>>n;
// int arr[100005];
// for(int i=1;i<=n;i++) cin>>arr[i];
// sort(arr+1,arr+n+1);
// if(n%2==0){
// cout<<"Outgoing #: "<<n/2<<endl;
// cout<<"Introverted #: "<<n/2<<endl;
// cout<<"Diff = ";
// int sumO=0,sumI=0;
// for(int i=1;i<=n;i++){
// if(i<=n/2) sumI+=arr[i];
// else sumO+=arr[i];
// }
// cout<<sumO-sumI;
// }
// else{
// cout<<"Outgoing #: "<<n/2+1<<endl;
// cout<<"Introverted #: "<<n/2<<endl;
// cout<<"Diff = ";
// int sumO=0,sumI=0;
// for(int i=1;i<=n;i++){
// if(i<=n/2) sumI+=arr[i];
// else sumO+=arr[i];
// }
// cout<<sumO-sumI;
// }
//}
//void solve(){
// int n; cin>>n;
// unordered_map<string,bool> follow;
// for(int i=1;i<=n;i++){
// string str; cin>>str;
// follow[str]=true;
// }
// int m; cin>>m;
// int tot=0;
// unordered_map<string,int> like;
// for(int i=1;i<=m;i++){
// string user; cin>>user;
// int num; cin>>num;
// like[user]=num;
// tot+=num;
// }
// vector<string> maybe;
// for(auto [user,num]:like){
// if(num>tot/m&&!follow[user]) maybe.e(user);
// }
// if(sz(maybe)==0) cout<<"Bing Mei You";
// else{
// sort(maybe.begin(),maybe.end());
// for(auto mb:maybe) cout<<mb<<endl;
// }
//}
//int n;
//double z,r,ans;
//vector<int> vct[100005];
//map<int,int> good;
//void dfs(int u,double power){
// if(good[u]!=0){
// ans+=good[u]*power;
// return;
// }
// for(auto v:vct[u]) dfs(v,power*(100-r)/100);
//}
//void solve(){
// cin>>n>>z>>r;
// for(int i=0;i<=n-1;i++){
// int k; cin>>k;
// if(k==0){
// int x; cin>>x;
// good[i]=x;
// }
// else for(int j=1;j<=k;j++){
// int x; cin>>x;
// vct[i].e(x);
// }
// }
// dfs(0,z);
// cout<<(int)ans; // 只保留整数部分,不四舍五入
//}
int bound=1e5;
const double PI=acos(-1);
void solve(){
double m,p; cin>>m>>p;
m/=100;
double E=1000;
double v=sqrt(2*E/m);
double vx=cos(PI/4)*v,vy=cos(PI/4)*v; // sqrt(2)/2 * v
double d=0;
while(bound--){
double t=2*vy/9.8;
d+=t*vx;
E-=E*(p/100); // 动能损失
v=sqrt(2*E/m);
vx=cos(PI/4)*v,vy=cos(PI/4)*v;
}
cout<<fixed<<setprecision(3)<<d;
// cout<<vx<<" "<<sqrt(2)/2;
// cout<<PI;
}
int32_t main() {
ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
int t=1;
// cin>>t;
while(t--){
solve();
}
return 0;
}
7-15 球队“食物链” - 2025寒假天梯赛训练7(22 23届)
思路:写了一发暴搜,30分的题拿22分,可以了。
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define sz(x) (int)x.size()
#define e emplace_back
//void solve(){
// cout<<"Hello World"<<endl<<"Hello New World";
//}
//void solve(){
// int a,b;
// cin>>a>>b;
// cout<<a*b;
//}
//void solve(){
// double a,b; cin>>a>>b;
// if(b==0) cout<<a<<"/"<<b<<"=Error";
// else{
// cout<<a<<"/";
// if(b<0) cout<<"("<<b<<")";
// else cout<<b;
// cout<<"="<<fixed<<setprecision(2)<<a/b;
// }
//}
//void solve(){
// cout<<fixed<<setprecision(2);
// int n; cin>>n;
// for(int i=1;i<=n;i++){
// char sex; cin>>sex;
// double tall; cin>>tall;
// if(sex=='M') cout<<tall/1.09<<endl;
// if(sex=='F') cout<<tall*1.09<<endl;
// }
//}
//bool check(int year,int n){
// unordered_set<int> st;
// if(year<1000) st.insert(0);
// while(year){
// st.insert(year%10);
// year/=10;
// }
// return n==sz(st);
//}
//void solve(){
// int n;
// string year; cin>>year>>n;
// for(int i=stoi(year);;i++){
// if(check(i,n)){
// cout<<i-stoi(year)<<" ";
// if(i<10) cout<<"000";
// else if(i<100) cout<<"00";
// else if(i<1000) cout<<"0";
// cout<<i;
// break;
// }
// }
//}
//void solve(){
// string A,B;
// string str;
// int cnt=0;
// while(true){
// cin>>str;
// if(str==".") break;
// cnt++;
// if(cnt==2) A=str;
// if(cnt==14) B=str;
// }
// if(cnt>=14) cout<<A+" and "<<B<<" are inviting you to dinner...";
// else if(cnt>=2) cout<<A+" is the only one for you...";
// else cout<<"Momo... No one is for you ...";
//}
//void solve(){
// int n; cin>>n;
// map<int,int> mp;
// for(int i=1;i<=n;i++){
// int k; cin>>k;
// for(int j=1;j<=k;j++){
// int x; cin>>x;
// mp[x]++;
// }
// }
// int num=0,cnt=0;
// for(auto [x,y]:mp){
// if(y>cnt) cnt=y,num=x;
// if(y==cnt) num=max(num,x);
// }
// cout<<num<<" "<<cnt;
//}
//char c[105][1005];
//void solve(){ // 有点点恶心的,,7-8 古风排版--20分
// int n; cin>>n; // 是每一列的字符数,即行数为n
// string str;
// cin.ignore();
// getline(cin,str);
cout<<str;
// int len=sz(str);
// int col=len/n;
// if(len%n!=0) col++;
cout<<col;
// for(int i=0;i<n;i++) for(int j=0;j<col;j++) c[i][j]=' ';
// for(int i=0;i<n;i++){
// for(int j=i,cnt=1;j<sz(str)&&cnt<=col;j+=n,cnt++){
// int lie=col-cnt;
// c[i][lie]=str[j];
// }
// }
// for(int i=0;i<n;i++){
// for(int j=0;j<col;j++){
// cout<<c[i][j];
// }
// cout<<endl;
// }
//}
//void solve(){
// int n; cin>>n;
// int arr[100005];
// for(int i=1;i<=n;i++) cin>>arr[i];
// sort(arr+1,arr+n+1);
// if(n%2==0){
// cout<<"Outgoing #: "<<n/2<<endl;
// cout<<"Introverted #: "<<n/2<<endl;
// cout<<"Diff = ";
// int sumO=0,sumI=0;
// for(int i=1;i<=n;i++){
// if(i<=n/2) sumI+=arr[i];
// else sumO+=arr[i];
// }
// cout<<sumO-sumI;
// }
// else{
// cout<<"Outgoing #: "<<n/2+1<<endl;
// cout<<"Introverted #: "<<n/2<<endl;
// cout<<"Diff = ";
// int sumO=0,sumI=0;
// for(int i=1;i<=n;i++){
// if(i<=n/2) sumI+=arr[i];
// else sumO+=arr[i];
// }
// cout<<sumO-sumI;
// }
//}
//void solve(){
// int n; cin>>n;
// unordered_map<string,bool> follow;
// for(int i=1;i<=n;i++){
// string str; cin>>str;
// follow[str]=true;
// }
// int m; cin>>m;
// int tot=0;
// unordered_map<string,int> like;
// for(int i=1;i<=m;i++){
// string user; cin>>user;
// int num; cin>>num;
// like[user]=num;
// tot+=num;
// }
// vector<string> maybe;
// for(auto [user,num]:like){
// if(num>tot/m&&!follow[user]) maybe.e(user);
// }
// if(sz(maybe)==0) cout<<"Bing Mei You";
// else{
// sort(maybe.begin(),maybe.end());
// for(auto mb:maybe) cout<<mb<<endl;
// }
//}
//int n;
//double z,r,ans;
//vector<int> vct[100005];
//map<int,int> good;
//void dfs(int u,double power){
// if(good[u]!=0){
// ans+=good[u]*power;
// return;
// }
// for(auto v:vct[u]) dfs(v,power*(100-r)/100);
//}
//void solve(){
// cin>>n>>z>>r;
// for(int i=0;i<=n-1;i++){
// int k; cin>>k;
// if(k==0){
// int x; cin>>x;
// good[i]=x;
// }
// else for(int j=1;j<=k;j++){
// int x; cin>>x;
// vct[i].e(x);
// }
// }
// dfs(0,z);
// cout<<(int)ans; // 只保留整数部分,不四舍五入
//}
//int bound=1e5;
//const double PI=acos(-1);
//void solve(){ // 简单物理题--非常弹的球--30分 写完这个还剩1小时30分钟,还有一题25分的,两题30分的.
// double m,p; cin>>m>>p;
// m/=100;
// double E=1000;
// double v=sqrt(2*E/m);
// double vx=cos(PI/4)*v,vy=cos(PI/4)*v; // sqrt(2)/2 * v
// double d=0;
// while(bound--){
// double t=2*vy/9.8;
// d+=t*vx;
// E-=E*(p/100); // 动能损失
// v=sqrt(2*E/m);
// vx=cos(PI/4)*v,vy=cos(PI/4)*v;
// }
// cout<<fixed<<setprecision(3)<<d;
cout<<vx<<" "<<sqrt(2)/2;
cout<<PI;
//}
int n;
char match[25][25];
bool vis[25];
deque<int> dq;
void dfs(int u){
for(int v=1;v<=n;v++){
if(!vis[v]&&(match[u][v]=='W'||match[v][u]=='L')){
vis[v]=true;
dq.e(v);
if(sz(dq)==n&&(match[dq.back()][dq.front()]=='W'||match[dq.front()][dq.back()]=='L')) return;
dfs(v);
if(sz(dq)==n&&(match[dq.back()][dq.front()]=='W'||match[dq.front()][dq.back()]=='L')) return;
dq.pop_back();
vis[v]=false;
}
}
}
void solve(){ // 7-15 球队“食物链”--30分的题,暴搜很好写,能拿22分,TLE8分,也可以了吧..
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cin>>match[i][j];
}
}
for(int i=1;i<=n;i++){
vis[i]=true;
dq.e(i);
dfs(i);
if(sz(dq)==n&&(match[dq.back()][dq.front()]=='W'||match[dq.front()][dq.back()]=='L')) break;
dq.pop_back();
vis[i]=false;
}
if(sz(dq)==n){
int cc=true;
while(!dq.empty()){
if(cc) cout<<dq.front(),cc=false;
else cout<<" "<<dq.front();
dq.pop_front();
}
}
else cout<<"No Solution";
}
int32_t main() {
ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
int t=1;
// cin>>t;
while(t--){
solve();
}
return 0;
}