1995
最后一个只移动一次,倒数第二个在第一轮移动一次,再移动到最下面的上面时候再增加一次,所以两次,以此类推,是平方。
解析
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int x, y, t;
cin>>t;
long long ans;
while(t--)
{
cin>>x>>y;
ans = 0;
ans = pow(2, x - y);
cout<<ans<<endl;
}
return 0;
}
1996
题意是说如果不按顺序放会有多少种情况,已知无论怎么放,一个柱子上的顺序一定,所以就只用考虑盘子分到哪个柱子,每盘子有三种情况,所以三次方
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int num;
int t;
long long ans;
cin>>t;
while(t--)
{
cin>>num;
ans = pow(3,num);
cout<<ans<<endl;
}
return 0;
}