分析: 你会发现每次往下都是除以2来平分,但是无论如何也不能是题目给的那么大呀。
这说明有单位换算,但是我们并不知道单位换算是咋换算的。但是可以知道的是,最后一层的最小数和最大数的比值在那种单位下都是不变的。故可以求出最后一行的最大数和最小数的比值,以此来求出最大值。
#include
using namespace std;
typedef long long int LL;
double a[105][105]=
{
{7},
{5,8},
{7,8,8},
{9,2,7,2},
{8,1,4,9,1},
{8,1,8,8,4,1},
{7,9,6,1,4,5,4},
{5,6,5,5,6,9,5,6},
{5,5,4,7,9,3,5,5,1},
{7,5,7,9,7,4,7,3,3,1},
{4,6,4,5,5,8,8,3,2,4,3},
{1,1,3,3,1,6,6,5,5,4,4,2},
{9,9,9,2,1,9,1,9,2,9,5,7,9},
{4,3,3,7,7,9,3,6,1,3,8,8,3,7},
{3,6,8,1,5,3,9,5,8,3,8,1,8,3,3},
{8,3,2,3,3,5,5,8,5,4,2,8,6,7,6,9},
{8,1,8,1,8,4,6,2,2,1,7,9,4,2,3,3,4},
{2,8,4,2,2,9,9,2,8,3,4,9,6,3,9,4,6,9},
{7,9,7,4,9,7,6,6,2,8,9,4,1,8,1,7,2,1,6},
{9,2,8,6,4,2,7,9,5,4,1,2,5,1,7,3,9,8,3,3},
{5,2,1,6,7,9,3,2,8,9,5,5,6,6,6,2,1,8,7,9,9},
{6,7,1,8,8,7,5,3,6,5,4,7,3,4,6,7,8,1,3,2,7,4},
{2,2,6,3,5,3,4,9,2,4,5,7,6,6,3,2,7,2,4,8,5,5,4},
{7,4,4,5,8,3,3,8,1,8,6,3,2,1,6,2,6,4,6,3,8,2,9,6},
{1,2,4,1,3,3,5,3,4,9,6,3,8,6,5,9,1,5,3,2,6,8,8,5,3},
{2,2,7,9,3,3,2,8,6,9,8,4,4,9,5,8,2,6,3,4,8,4,9,3,8,8},
{7,7,7,9,7,5,2,7,9,2,5,1,9,2,6,5,3,9,3,5,7,3,5,4,2,8,9},
{7,7,6,6,8,7,5,5,8,2,4,7,7,4,7,2,6,9,2,1,8,2,9,8,5,7,3,6},
{5,9,4,5,5,7,5,5,6,3,5,3,9,5,8,9,5,4,1,2,6,1,4,3,5,3,2,4,1}
};//29 共30
int main(void)
{
for(int i=0;i<29;i++)
{
for(int j=0;j<=i;j++)
{
a[i+1][j]+=a[i][j]/2;
a[i+1][j+1]+=a[i][j]/2;
}
}
double maxv=0,minv=1e9;
for(int i=0;i<=29;i++)
{
minv=min(minv,a[29][i]);
maxv=max(maxv,a[29][i]);
}
long long int ans=2086458231/minv*maxv;
printf("%lld\n",ans);
return 0;
}
#include
using namespace std;
string s;
map<string,int>mp;
int main(void)
{
/*freopen("1.txt","r",stdin);
while(cin>>s)
{
mp[s]++;
}
fclose(stdin);
cin.clear();//当多个文件流读入的时候
freopen("2.txt","r",stdin);
while(cin>>s)
{
mp[s]++;
}
fclose(stdin);
cin.clear();
freopen("3.txt","r",stdin);
while(cin>>s) mp[s]--;
int cnt=0;
for(auto i=mp.begin();i!=mp.end();i++) if(i->second==2) cnt++;
cout<
cout<<20;
return 0;
}
#include
using namespace std;
char get(int x){return 'A'+(x-1+26)%26;}
int n;
int main(void)
{
while(cin>>n)
{
string s;
while(n)
{
int t=n%26;
s=get(t)+s;
n=(n-1)/26;
}
cout<<s<<endl;
}
return 0;
}
#include
using namespace std;
string a,b;
int main(void)
{
while(cin>>a>>b)
{
deque<char>q1,q2,q3;
for(int i=0;i<a.size();i++) q1.push_back(a[i]);
for(int i=0;i<b.size();i++) q2.push_back(b[i]);
int flag=0,cnt=0;
map<char,int>mp;
while(cnt<=1000000)
{
if(!q1.size()||!q2.size()) break;
if(!flag)
{
if(!q1.size()) break;
char c=q1.front(); q1.pop_front();
if(mp[c])
{
q1.push_back(c);
while(q3.back()!=c)
{
q1.push_back(q3.back());
mp[q3.back()]--;
q3.pop_back();
}
q1.push_back(q3.back());
mp[q3.back()]--;
q3.pop_back();
if(!q2.size()) break;
}else mp[c]++,flag=1,q3.push_back(c);
}
else
{
if(!q2.size()) break;
char c=q2.front(); q2.pop_front();
if(mp[c])
{
q2.push_back(c);
while(q3.back()!=c)
{
q2.push_back(q3.back());
mp[q3.back()]--;
q3.pop_back();
}
q2.push_back(q3.back());
mp[q3.back()]--;
q3.pop_back();
if(!q1.size()) break;
}
else mp[c]++,flag=0,q3.push_back(c);
}
cnt++;
}
if(q1.size()&&q2.size()) cout<<-1;
else
{
while(q1.size()) cout<<q1.front(),q1.pop_front();
while(q2.size()) cout<<q2.front(),q2.pop_front();
}
cout<<'\n';
}
return 0;
}
#include
using namespace std;
int a[15],cnt;
map<deque<int>,int>mp;
int main(void)
{
for(int i=0;i<9;i++) a[i]=i+1;
do
{
int len1=a[0]+a[1]+a[2]+a[3];
int len2=a[3]+a[4]+a[5]+a[6];
int len3=a[0]+a[8]+a[7]+a[6];
if(len1==len2&&len2==len3) cnt++;
}while(next_permutation(a,a+9));
cout<<cnt/6<<endl;
return 0;
}
#include
using namespace std;
//A B C D E,F G H I
char a[10]={'I','A','B','C','D','E','F','G','H'};
int main(void)
{
string s="651764141421415346185";
int n=0;
for(int i=0;i<s.size();i++) n+=s[i]-'0';
int ans=n%9;
cout<<a[ans]<<endl;
return 0;
}
#include
using namespace std;
string a,b;
int dx[6]={-1,1,-2,2,-3,3};
int bfs()
{
int n=a.size();
map<string,int>mp;
queue<string>q; q.push(a); mp[a]=0;
while(q.size())
{
string s=q.front(); q.pop();
if(s==b) return mp[s];
int x=s.find('*');
for(int i=0;i<6;i++)
{
int tempx=x+dx[i];
if(tempx<0||tempx>=n) continue;
string temp=s;
swap(temp[x],temp[tempx]);
if(mp.count(temp)) continue;
mp[temp]=mp[s]+1;
q.push(temp);
}
}
}
int main(void)
{
while(cin>>a>>b) cout<<bfs()<<'\n';
return 0;
}
#include
using namespace std;
typedef long long int LL;
const int N=1e5+10;
LL a[N],b[N],n,m;
bool check(int mid)
{
LL cnt=0;
for(int i=0;i<n;i++) cnt+=(a[i]/mid)*(b[i]/mid);
return cnt>=m;
}
int main(void)
{
cin>>n>>m;
for(int i=0;i<n;i++) cin>>a[i]>>b[i];
int l=0,r=1e9;
while(l<r)
{
int mid=l+r+1>>1;
if(check(mid)) l=mid;
else r=mid-1;
}
cout<<l;
return 0;
}
5200
#include
using namespace std;
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int a,b,c;
bool judge(int x)
{
if(x%400==0||(x%4==0&&x%100!=0)) return true;
return false;
}
bool check(int s1,int s2,int s3)
{
if( s1==a && s2==b && s3==c ) return true;
return false;
}
int main(void)
{
scanf("%d/%d/%d",&a,&b,&c);
for(int i=19600101;i<=20591231;i++)
{
int s1=i/10000;
int s2=(i%10000)/ 100;
int s3=i%100;
if(judge(s1)) month[2]=29;
if(s1>=1&&s2<=12&&s3>=1&&s3<=month[s2])
if(check(s1%100,s2,s3) || check(s2,s3,s1%100) || check(s3,s2,s1%100))
{
printf("%04d-%02d-%02d\n",s1,s2,s3);
}
month[2]=28;
}
return 0;
}
#include
using namespace std;
const int N=1e5+10;
typedef long long int LL;
LL a[N],s[N],st[N],n,k;
int main(void)
{
cin>>n>>k;
for(int i=1;i<=n;i++) cin>>a[i],s[i]=s[i-1]+a[i];
st[0]++;
LL ans=0;
for(int i=1;i<=n;i++)
{
int t=s[i]%k;
ans+=st[t];
st[t]++;
}
cout<<ans;
return 0;
}
#include
using namespace std;
string s[10]=
{
"UDDLUULRUL",
"UURLLLRRRU",
"RRUURLDLRD",
"RUDDDDUUUU",
"URUDLLRRUU",
"DURLRLDLRL",
"ULLURLLRDU",
"RDLULLRDDD",
"UUDDUDUDLL",
"ULRDLUURRR"
};
int st[15][15],ans;
void dfs(int x,int y)
{
if(x<0||x>9||y<0||y>9)//过界
{
ans++;
return;
}
if(st[x][y]) return;//是一个圈
st[x][y]=1;
if(s[x][y]=='U') dfs(x-1,y);
if(s[x][y]=='D') dfs(x+1,y);
if(s[x][y]=='L') dfs(x,y-1);
if(s[x][y]=='R') dfs(x,y+1);
}
int main(void)
{
for(int i=0;i<10;i++)
for(int j=0;j<10;j++)
{
memset(st,0,sizeof st);
dfs(i,j);
}
cout<<ans;
return 0;
}
#include
#include
using namespace std;
int n=6;
int ans;
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
int vis[7][7];
void dfs(int x,int y)
{
if(x==0||x==6||y==0||y==6) //剪到边就剪完了
{
ans++;
return;
}
for(int i=0;i<4;i++)
{
int tempx=x+dx[i];
int tempy=y+dy[i];
if(!vis[tempx][tempy])
{
vis[tempx][tempy]=true;
vis[n-tempx][n-tempy]=true;
dfs(tempx,tempy);
vis[tempx][tempy]=false;
vis[n-tempx][n-tempy]=false;
}
}
}
int main(void)
{
vis[n/2][n/2]=true;
dfs(n/2,n/2);
cout<<ans/4<<endl;
return 0;
}