以下所有AC题解程序来自“仙客传奇”团队。
题解链接:
ABDFHK "字节跳动杯"2018中国大学生程序设计竞赛-女生专场
AC的C++语言程序:
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
#define ull unsigned long long
bool check(ull a,ull b,ull k,ull n){
ull ans=1,ans1=1;
for(int i=1;i<=a;i++){
if(ans<k/n) ans*=n;
else return false;
}
ull tmp=ceil(log2(n));
for(int i=1;i<=b;i++){
if(ans1<k/tmp) ans1*=tmp;
else return false;
}
if(ans<=k/ans1) return true;
else return false;
}
int main(){
//freopen("in.txt","r",stdin);
int T;
cin>>T;
while(T--){
ull a,b,k;
cin>>a>>b>>k;
ull l=2,r=(ull)1e18;
while(l<=r){
ull mid=(l+r)/2;
if(check(a,b,k,mid)) l=mid+1;
else r=mid - 1;
}
cout<<l-1<<endl;
}
return 0;
}
题解链接:
HDU - 6289 寻宝游戏 详解(DP)
AC的C++语言程序:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXM=200500;
const int MAXN=100500;
struct edge{
int u;
int v;
int a;
int b;
int next;
}e[MAXM];
int edge_num,head[MAXN];
void insert_edge(int u,int v,int a,int b){
e[edge_num].u=u;
e[edge_num].v=v;
e[edge_num].a=a;
e[edge_num].b=b;
e[edge_num].next=head[u];
head[u]=edge_num++;
}
struct Node{
int id;
ll d;
Node(int id, ll d):id(id),d(d){}
bool operator < (const Node &A)const{
return d > A.d;
}
};
ll d[MAXN];
bool vis[MAXN];
int dijkstra(int S,int T){
memset(d,0x3f,sizeof(d));
memset(vis,0,sizeof(vis));
priority_queue<Node> que;
que.push(Node(S,1));
d[S]=1;
while(!que.empty()){
Node tp1=que.top();
que.pop();
int tp=tp1.id;
if(tp==T){
for(int i=1;;i++)
if((1LL<<i)>tp1.d)
return i-1;
}
if(vis[tp])
continue;
vis[tp]=1;
for(int i=head[tp];i!=-1;i=e[i].next){
if(vis[e[i].v])
continue;
if(((e[i].a+tp1.d)/(tp1.d))>=(1LL<<e[i].b)&&e[i].a+tp1.d<d[e[i].v]){
d[e[i].v]=e[i].a+tp1.d;
que.push(Node(e[i].v,d[e[i].v]));
}
}
}
return -1;
}
int main()
{
int T;
scanf("%d",&T);
while(T--){
memset(head,-1,sizeof(head));
edge_num=0;
int u,v,a,b;
int N,M;
scanf("%d%d",&N,&M);
for(int i=0;i<M;i++){
scanf("%d%d%d%d",&u,&v,&a,&b);
insert_edge(u,v,a,b);
}
printf("%d\n",dijkstra(1,N));
}
return 0;
}
题解链接:
HDU - 6291 对称数 (树上莫队+分块) (2018CCPC女生赛)
HDU 6291:对称数
hdu6291 对称数(树上莫队+查询分块)
AC的C++语言程序:
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
int main(){
int T;
scanf("%d",&T);
for(int cas=1000+1;cas<=1000+T;cas++){
int n,m,ansn=1000000,ansm=1000000;
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++) {
int tmp;scanf("%d",&tmp);
ansn=min(ansn,tmp);
}
for(int i=0;i<m;i++){
int tmp;
scanf("%d",&tmp);
ansm=min(ansm,tmp);
}
printf("Problem %d:\n",cas);
if(n) printf("Shortest judge solution: %d bytes.\n",ansn);
if(m) printf("Shortest team solution: %d bytes.\n",ansm);
else printf("Shortest team solution: N/A bytes.\n");
}
}
AC的C++语言程序:
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+10;
char s[maxn];
string v;
int main(){
//freopen("in.txt","r",stdin);
int T;
scanf("%d",&T);
while(T--){
v.clear();
int n;
scanf("%d",&n);
scanf("%s",s);
char ch;
if(s[n-2]>s[n-1]) v.push_back('>'),ch='>';
else if(s[n-2]<s[n-1]) v.push_back('<'),ch='<';
else if(s[n-2]==s[n-1]){
v.push_back('>'),ch='>';
}
for(int i=n-3;i>=0;i--){
if(s[i]>s[i+1]) v.push_back('>'),ch='>';
else if(s[i]<s[i+1]) v.push_back('<'),ch='<';
else if(s[i]==s[i+1]) v.push_back(ch);
}
reverse(v.begin(),v.end());
printf("%s\n",v.c_str());
}
}
题解链接:
HDU 6295 回文树(双指针)
题解链接:
HDU 6296 代码派对
HDU 6296 代码派对
AC的C++语言程序:
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
int main(){
int T;scanf("%d",&T);
while(T--){
int rk,prb,wh;
string ne,ans;
cin>>rk>>ne>>prb>>ans;
if(ans=="Running") cin>>wh;
printf("%3d|",rk);
cout<<ne;
for(int i=0;i<16-ne.size();i++) printf(" ");
printf("|");
cout<<prb<<"|[";
if(ans=="Running"){
for(int i=0;i<wh;i++) printf("X");
for(int i=0;i<10-wh;i++) printf(" ");
printf("]\n");
}else {
for(int i=0;i<4;i++) printf(" ");
if(ans=="FB"){
printf("AC*");
for(int i=0;i<10-7;i++)printf(" ");
printf("]\n");
}else {
cout<<ans;
for(int i=0;i<10-ans.size()-4;i++) printf(" ");
printf("]\n");
}
}
}
}
题解链接:
ABDFHK "字节跳动杯"2018中国大学生程序设计竞赛-女生专场