ACM-ICPC 2016 沈阳赛区现场赛 A,B

题目链接: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;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值