题目链接:Thickest Burger
#include<bits/stdc++.h>
using namespace std;
int main (){
int t;cin>>t;
while(t--){
int a,b;cin>>a>>b;
cout<<max(a*2+b,b*2+a)<<endl;
}
return 0;
}
题目链接: Relative atomic mass
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main (){
int t;cin>>t;
while(t--){
ll ans=0;
string ss;cin>>ss;
for(auto x:ss){
if(x=='H') ans++;
else if(x=='C') ans+=12;
else ans+=16;
}
cout<<ans<<endl;
}
return 0;
}
题目链接: Recursive sequence
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define ll long long
const ll maxn = 7;
const ll mod = 2147493647;
struct mat{
ll m[maxn][maxn];
};
mat operator *(mat x, mat y){
mat ret;
for(int i = 0; i < maxn; i++){
for(int j = 0; j < maxn; j++){
ret.m[i][j] = 0;
for(int k = 0; k < maxn; k++)
ret.m[i][j] = (x.m[i][k] * y.m[k][j] + ret.m[i][j]) % mod;
}
}
return ret;
}
mat pow_mat(mat a, ll n){
mat ret;
memset(ret.m,0,sizeof(ret.m));
for(int i = 0; i < maxn; i++) ret.m[i][i] = 1;
while(n){
if(n&1) ret = ret*a;
a = a*a;
n >>= 1;
}
return ret;
}
int main(){
int t;
scanf("%d",&t);
while(t--){
ll f1, f2, m;
scanf("%lld %lld %lld",&m,&f1,&f2);
if(m == 1) printf("%lld\n",f1);
else if(m == 2) printf("%lld\n",f2);
else{
mat a;
memset(a.m,0,sizeof(a.m));
a.m[0][0] = f2;
a.m[1][0] = f1;
a.m[2][0] = 1;
a.m[3][0] = 2;
a.m[4][0] = 4;
a.m[5][0] = 8;
a.m[6][0] = 16;
mat b ={
1, 2, 1, 4, 6, 4, 1,
1, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0,
0, 0, 1, 1, 0, 0, 0,
0, 0, 1, 2, 1, 0, 0,
0, 0, 1, 3, 3, 1, 0,
0, 0, 1, 4, 6, 4, 1
};
a = pow_mat(b,m-2)*a;
printf("%lld\n",a.m[0][0]);
}
}
return 0;
}