蒟蒻的来做梦8.24总结

· · 个人记录

应该没人写了笔记吧但还是放一个黑板:

T640711 快递费用

轻水反应堆。

#include<iostream>
#include<array>
using namespace std;
constexpr array<int,5>p={4,6,9,10,17};
int w,n;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin>>w>>n;
    if(w<500){
        cout<<20;
    }else{
        w-=500;
        int ans=20;
        while(w>500){
            w-=500;
            ans+=p[n-1];
        }
        cout<<ans+p[n-1];
    }
    return 0;
}

T638889 石头布没有剪刀

重水反应堆。

#include<iostream>

using namespace std;
string s;
int x,y,ans;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin>>s;
    for(auto i:s){
        if(i=='g'){
            //rock->p
            if(x>y){
                y++;
                ans++;
            }else{
                x++;
            }
        }else{
            if(x>y){
                y++;
            }else{
                x++;
                ans--;
            }
        }
    }
    cout<<ans;
    return 0;
}

T644252 篝火问题

思路:烟动太费时,篝火和人动,篝火走的时候留下烟。

#include<iostream>
#include<map>
using namespace std;
int n,r,c,mr,mc;
string s;
map<int,map<int,bool>>vis;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin>>n>>r>>c>>s;
    for(auto i:s){
        vis[mr][mc]=1;//烟来啦!
        switch(i){
            case 'N':{
                r++;
                mr++;
                break;
            }
            case 'W':{
                c++;
                mc++;
                break;
            }
            case 'S':{
                r--;
                mr--;
                break;
            }
            case 'E':{
                c--;
                mc--;
                break;
            }
        }
        cout<<vis[r][c];
    }
    return 0;
}

T639146 落落的去的数学问题3

用前缀和和数学拼接。

#include<iostream>
#include<sstream>
#include<vector>
#include<cmath>
using namespace std;
using ll=long long;
constexpr ll mod=998244353;
ll n,ans;
vector<ll>v,fn;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin>>n;
    v.resize(n);
    for(auto &&i:v){
        cin>>i;
    }
    fn.resize(n);
    fn[0]=v[0]%mod;
    for(ll i=1;i<n;i++){
        fn[i]=(fn[i-1]+v[i])%mod;
    }
    for(ll i=1;i<n;i++){
        ll len=to_string(v[i]).size();
        ans+=(
        fn[i-1]%mod
        *(ll(pow(10,len)+0.5)%mod)
        +(i)*v[i]%mod
        )%mod;
        ans%=mod;
    }
    cout<<ans%mod;
    return 0;
}

P1100 高低位交换

位运算。

#include<iostream>

using namespace std;
unsigned n;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin>>n;
    cout<<((n<<16)|(n>>16));
    return 0;
}

本页面的全部内容在CC BY-NC-ND 4.0 和 SATA 协议之条款下提供,附加条款亦可能应用