日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

2020牛客暑期多校训练营(第四场)

發布時間:2023/12/3 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2020牛客暑期多校训练营(第四场) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2020牛客暑期多校訓練營(第四場)
這場屬實有點難受

文章目錄

    • A Ancient Distance
    • B Basic Gcd Problem
      • 題目
      • 代碼:
    • C Count New String
    • D Dividing Strings
    • E Eliminate++
    • F Finding the Order
      • 題意:
      • 題解:
      • 代碼:
    • G Geometry Challenge
    • H Harder Gcd Problem
    • I Investigating Legions
    • J Jumping on the Graph

A Ancient Distance

B Basic Gcd Problem

爺被卡自閉了

題目

仔細分析題其實就是問cf(x)等于等于多少
而f(x)等于什么呢?
唯一分解定理

而我們要做的就是求出f(x)=a1+a2+a3+…an
pow(c,sum)
我被int和longlong卡了,快速冪我用的longlong結果超時了
其實思路不難,多注意細節

代碼:

#include <iostream> #include <stdio.h> #include<vector> #include<queue> #include<math.h> #include<algorithm> #include<string.h> using namespace std; typedef long long ll; const int maxn=1e6+3; const ll mod=1e9+7; ll sum=0; ll spr[maxn],zs[maxn],ds[maxn]; inline ll poww(ll a,ll b,ll p) {ll res=1;ll base=a%p;while(b){if(b&1){res=(res*base)%p;}base=( base*base)%p;b>>=1;}return res%p; } //template <typename T> //inline void read(T &s){ // T t=1; char k=getchar(); s=0; // for (;k<'0'||k>'9';k=getchar()) if (k=='-') t=-1;//判斷該數正負 // for (;k>='0'&&k<='9';k=getchar()) s=(s<<1)+(s<<3)+(k^48);//<<1加上<<3就相當于*10,但是位運算的速度較快,^48也相當于-‘0’,同理,較快。 // s*=t; //} //void olp(){ //先打表,歐拉篩 // memset(is,true,sizeof is); // is[0] = is[1] = 0; // for(int i=2;i<maxn;i++){ // if(is[i]) spr[cnt++]= i; // for(int j=0;i*spr[j]<maxn&&j<cnt;j++){ // is[i*spr[j]] = 0; // if(i%spr[j]==0) break; // } // } //} void fj(int x){ //不同素數的個數for(int i=2;i*i<=x;i++){while(x%i==0){x/=i,sum++; }}if(x!=1){ //如果分解玩x都不等于1,那么x必定是一個素數sum++;}return ; } int main(){//olp();int t;scanf("%d",&t);while(t--){ll n,c;scanf("%lld%lld",&n,&c);// cout<<n<<" "<<c<<endl;sum=0;fj(n);ll ww=poww(c,sum,mod);printf("%lld\n",ww);}return 0; }

C Count New String

D Dividing Strings

E Eliminate++

F Finding the Order

題意:

兩條平行直線,上一條是ab(a在左邊,b在右邊),下一條是dc(但是d和c誰在左誰在右未知)
現在給你,ac,ad,bc,bd的長度,問d和c誰在左誰在右

題解:

畫圖分析一下
三種情況:cd正常,c很遠,d很遠
圖中是cd的情況
而dc的情況剛好相反

代碼:

#include<bits/stdc++.h> #define rg register using namespace std; // scanf("%d",); // printf("%d",); int gcd(int a,int b) {if(b==0)return a;else return gcd(b,a%b); } inline int read(){int s=0,w=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();return s*w; } int main() {int t;t=read();while(t--){int ac=read(),ad=read(),bc=read(),bd=read();if(ac<=ad&&bc>=bd){printf("AB//CD\n");}else if(ac>=ad&&bc>=bd&&ac<bc){printf("AB//CD\n");}else if(ac<=ad&&bc<=bd&&ad>bd){printf("AB//CD\n");}else printf("AB//DC\n");}return 0; }//printf("AB//CD\n"); //printf("AB//DC\n");

G Geometry Challenge

H Harder Gcd Problem

I Investigating Legions

J Jumping on the Graph

總結

以上是生活随笔為你收集整理的2020牛客暑期多校训练营(第四场)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。