ACM-ICPC 2018 徐州赛区网络预赛(9.9)

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e6+10;
const int mod=1e9+7;
int dp[maxn][3];
int quick(int a,int n)
{
    int ans=1;
    int x=a;
    while(n!=0)
    {
        if(n%2==1) {ans=ans%mod*x%mod; n--; }
        else       { x=x%mod*x%mod;n=n/2;  }
    }
    return ans%mod;
}
int32_t main()
{
    int T; cin>>T;
    while(T--)
    {
        memset(dp,0,sizeof(dp));
        int n,k; cin>>n>>k;
        k=quick(2,k);
        dp[1][0]=k%mod;//  1
        dp[1][1]=0;// qi ta
        dp[1][2]=0;// bu neng de
        for(int i=2;i<=n;i++)
        {
            dp[i][0]=dp[i-1][0]%mod+dp[i-1][1]%mod;
            dp[i][1]=dp[i-1][0]*(k-2)+dp[i-1][1]*(k-3)%mod+dp[i-1][2]*(k-2)%mod;
            dp[i][2]=dp[i-1][2]%mod+dp[i-1][1]%mod;
            dp[i][0]=dp[i][0]%mod;
            dp[i][1]=dp[i][1]%mod;
            dp[i][2]=dp[i][2]%mod;
           // cout<<dp[i][0]<<"  "<<dp[i][1]<<"  "<<dp[i][2]<<endl;
        }
        cout<<(dp[n][0]+dp[n][1])%mod<<endl;
    }
}

A.cpp

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int T; scanf("%d",&T);
    while(T--)
    {
        map<pair<int,int>,int> mp;
        map<pair<int,int>,int> tf;
        int num; scanf("%d",&num);
        int ans=0;
        for(int i=1;i<=num;i++)
        {
            int k;  scanf("%d",&k);
            for(int j=1;j<=k;j++)
            {
                int a,b; scanf("%d %d",&a,&b);
                if(tf[{a,b}]==i) continue;
                if(tf[{a,b}]==i-1)
                {
                      tf[{a,b}]=i;
                      mp[{a,b}]++;
                      if(mp[{a,b}]>ans) ans=mp[{a,b}];
                }
                else
                {
                      tf[{a,b}]=i;
                      mp[{a,b}]=1;
                      if(mp[{a,b}]>ans) ans=mp[{a,b}];
                }
            }
        }printf("%d\n",ans);
    }
}

F.cpp

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int T; cin>>T;
    while(T--)
    {
        int n; char z;
        cin>>n>>z;
        string ss; cin>>ss;
        int ans=0;
        int t=0;
        for(int i=0;i<n;i++)
        {
            int k=abs(z-ss[i]);
            if(t==0)
            {
                if(k==0) continue;
                else
                {
                    if(k<10) ans+=1;
                    else if(k<100) ans+=2;
                    else if(k<1000) ans+=3;

                }
                t=1;
            }
            else if(t==1) ans+=2;
        }
        if(ans==0) ans=1;
        cout<<ans<<endl;
    }
}

I.cpp

原文地址:https://www.cnblogs.com/Andromeda-Galaxy/p/9621770.html

时间: 2024-10-07 17:51:20

ACM-ICPC 2018 徐州赛区网络预赛(9.9)的相关文章

ACM-ICPC 2018 徐州赛区网络预赛 D. EasyMath

ACM-ICPC 2018 徐州赛区网络预赛 D. EasyMath 做法: \[f(m,n) = \sum _{i=1}^{m} \mu(in) = \sum_{i=1}^{m}[gcd(i,n)=1]\mu(i)\mu(n) = \mu(n)\sum_{d|n}\mu(d)f(\frac{m}{d},d)\] 边界: n=1,杜教筛求\(\sum_{i=1}^{m}\mu(i)\),m = 1, 返回\(\mu(n)\),预处理尽可能把空间卡满. 2个小时的时候就推出来了这个式子,不会算复杂

ACM-ICPC 2018 徐州赛区网络预赛 H. Ryuji doesn&#39;t want to study

262144K Ryuji is not a good student, and he doesn't want to study. But there are n books he should learn, each book has its knowledge a[i]a[i]. Unfortunately, the longer he learns, the fewer he gets. That means, if he reads books from ll to rr, he wi

ACM-ICPC 2018 徐州赛区网络预赛 H. Ryuji doesn&#39;t want to study (线段树)

Ryuji is not a good student, and he doesn't want to study. But there are n books he should learn, each book has its knowledge a[i]a[i]. Unfortunately, the longer he learns, the fewer he gets. That means, if he reads books from ll to rr, he will get a

ACM-ICPC 2018 徐州赛区网络预赛 B. BE, GE or NE

In a world where ordinary people cannot reach, a boy named "Koutarou" and a girl named "Sena" are playing a video game. The game system of this video game is quite unique: in the process of playing this game, you need to constantly fac

ACM-ICPC 2018 徐州赛区网络预赛 J. Maze Designer (最大生成树+LCA求节点距离)

ACM-ICPC 2018 徐州赛区网络预赛 J. Maze Designer J. Maze Designer After the long vacation, the maze designer master has to do his job. A tour company gives him a map which is a rectangle. The map consists of N \times MN×M little squares. That is to say, the h

ICPC 2018 徐州赛区网络赛

ACM-ICPC 2018 徐州赛区网络赛 ?去年博客记录过这场比赛经历:该死的水题 ?一年过去了,不被水题卡了,但难题也没多做几道.水平微微有点长进. ? ? D. Easy Math 题意: ? 给定 \(n\), \(m\) ,求 \(\sum _{i=1}^{m} \mu(in)\) .其中 $ 1 \le n \le 1e12$ , $ 1 \le m \le 2e9$ ,\(\mu(n)\) 为莫比乌斯函数. ? 思路: ? 容易知道,\(i\) 与 \(n\) 不互质时, \(\m

ACM-ICPC 2018 徐州赛区网络预赛

Rank Solved A B C D E F G H I J K 157/1526 7/11 O O ? ? . O O O O O ? O: 当场通过 ?: 赛后通过 .: 尚未通过 A Hard to prepare solved by chelly chelly's solution B BE, GE or NE solved by ch ch's solution C Cacti Lottery upsolved by chelly chelly's solution 考虑枚举*代表的

ACM-ICPC 2018 徐州赛区网络预赛 A. Hard to prepare

传送门:https://nanti.jisuanke.com/t/31453 本题是一个组合数学(DP,滑稽)题. 一个环上有N个位置,标号为1~N.设第i(1≤i≤N)个位置上的数为x[i],限制条件为:0≤x[i]<2k.另有限制条件:当位置i和位置j相邻时,x[i]⊕x[j]≠2k-1.求满足限制条件的环的状态数. 可以考虑将环切割成链,以分析问题.设: ①a[n]:长度为n,且首尾相同的满足上述条件的链的状态数: ②b[n]:长度为n,且首尾相反的满足上述条件的链的状态数: ③c[n]:

【ACM-ICPC 2018 徐州赛区网络预赛】E. End Fantasy VIX 血辣 (矩阵运算的推广)

Morgana is playing a game called End Fantasy VIX. In this game, characters have nn skills, every skill has its damage. And using skill has special condition. Briefly speaking, if this time you use skill "x", then next time you can use skill &quo