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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

2017.10.25水题大作战题解

發布時間:2023/12/20 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2017.10.25水题大作战题解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

?

?

rank:

?

?

T1P1615 西游記公司

https://www.luogu.org/problemnew/show/P1615

scanf直接秒

1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #define LL long long 6 using namespace std; 7 inline LL read() 8 { 9 char c=getchar();LL x=0,f=1; 10 while(c<'0'||c>'9') {if(c=='-') f=-1;c=getchar();} 11 while(c>='0'&&c<='9') x=x*10+c-48,c=getchar();return x*f; 12 } 13 int main() 14 { 15 LL a,b,c,d,e,f,n; 16 scanf("%lld:%lld:%lld%lld:%lld:%lld%lld",&a,&b,&c,&d,&e,&f,&n); 17 printf("%lld",n*(f-c+60*(e-b)+3600*(d-a))); 18 return 0; 19 } View Code

T2P1838 三子棋I

https://www.luogu.org/problemnew/show/P1838

判斷好每一種情況,不要忘了平局

1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #define LL long long 6 using namespace std; 7 const int MAXN=201; 8 inline int read() 9 { 10 char c=getchar();int flag=1,x=0; 11 while(c<'0'||c>'9') {if(c=='-') flag=-1;c=getchar();} 12 while(c>='0'&&c<='9') x=(x*10+c-48),c=getchar(); return x*flag; 13 } 14 int a[MAXN][MAXN]; 15 char s[MAXN]; 16 int hang[MAXN]; 17 int lie[MAXN]; 18 int hang2[MAXN]; 19 int lie2[MAXN]; 20 int main() 21 { 22 int n=3; 23 scanf("%s",s+1); 24 int now=1; 25 for(int i=1;i<=strlen(s+1);i++) 26 { 27 int p=(int)s[i]-48; 28 if(p%3!=0) 29 { 30 a[p/3+1][p%3]=now; 31 if(now==1) hang[p/3+1]++, lie[p%3]++; 32 else hang2[p/+1]++, lie2[p%3]++; 33 } 34 else 35 { 36 a[p/3][3]=now; 37 if(now==1) hang[p/3]++, lie[3]++; 38 else hang2[p/3]++, lie2[3]++; 39 } 40 if(now==1) now=0;else now=1; 41 } 42 for(int i=1;i<=3;i++) 43 if(hang[i]==3||lie[i]==3) 44 { printf("xiaoa wins."); return 0; } 45 if((a[1][1]==1&&a[2][2]==1&&a[3][3]==1)||(a[1][3]==1&&a[2][2]==1&&a[3][1]==1)) 46 { printf("xiaoa wins."); return 0; } 47 for(int i=1;i<=3;i++) 48 if(hang2[i]==3||lie2[i]==3) 49 { printf("uim wins."); return 0; } 50 if((a[1][1]==0&&a[2][2]==0&&a[3][3]==0)||(a[1][3]==0&&a[2][2]==0&&a[3][1]==0)) 51 { printf("uim wins."); return 0; } 52 printf("drew."); 53 return 0; 54 } View Code

T3P1319 壓縮技術

https://www.luogu.org/problemnew/show/P1319

根據題意模擬即可

1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #define LL long long 6 using namespace std; 7 const int MAXN=201; 8 inline int read() 9 { 10 char c=getchar();int flag=1,x=0; 11 while(c<'0'||c>'9') {if(c=='-') flag=-1;c=getchar();} 12 while(c>='0'&&c<='9') x=(x*10+c-48),c=getchar(); return x*flag; 13 } 14 int n; 15 int main() 16 { 17 n=read(); 18 int now=0; 19 int how=1;//zero 20 int p; 21 while(cin>>p) 22 { 23 for(int i=1;i<=p;i++) 24 { 25 if(how==1) printf("0"); 26 else printf("1"); 27 now++; 28 if(now==n) printf("\n"),now=0; 29 } 30 if(how==1) how=0; 31 else how=1; 32 } 33 return 0; 34 } View Code

T4P2077 紅綠燈

https://www.luogu.org/problemnew/show/P2077

模擬汽車的行走路線,注意在經過紅綠燈的時候取模

1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #define LL long long 6 using namespace std; 7 const int MAXN=200001; 8 inline int read() 9 { 10 char c=getchar();int flag=1,x=0; 11 while(c<'0'||c>'9') {if(c=='-') flag=-1;c=getchar();} 12 while(c>='0'&&c<='9') x=(x*10+c-48),c=getchar(); return x*flag; 13 } 14 int n,m; 15 int dis[MAXN]; 16 int green[MAXN]; 17 int red[MAXN]; 18 int get(int pos,int val) 19 { 20 int now=val%(green[pos]+red[pos]); 21 if(now<=green[pos]) return 0; 22 return red[pos]-(now-green[pos]); 23 } 24 int main() 25 { 26 n=read(),m=read(); 27 for(int i=1;i<=n-1;i++) dis[i]=read(); 28 for(int i=1;i<=n;i++) red[i]=read(); 29 for(int i=1;i<=n;i++) green[i]=read(); 30 int now=m; 31 for(int i=1;i<=n;i++) 32 { 33 now=now+get(i,now); 34 printf("%d\n",now); 35 now+=dis[i]; 36 } 37 return 0; 38 } View Code

T5P2043 質因子分解

https://www.luogu.org/problemnew/show/P2043

枚舉1-n,依次進行分解

1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #define LL long long 6 using namespace std; 7 const LL MAXN=200001; 8 inline LL read() 9 { 10 char c=getchar();LL flag=1,x=0; 11 while(c<'0'||c>'9') {if(c=='-') flag=-1;c=getchar();} 12 while(c>='0'&&c<='9') x=(x*10+c-48),c=getchar(); return x*flag; 13 } 14 LL n; 15 LL vis[MAXN]; 16 LL prime[MAXN]; 17 LL tot=0; 18 LL ans[MAXN]; 19 int main() 20 { 21 n=read(); 22 vis[1]=1; 23 for(LL i=1;i<=10000;i++) 24 { 25 if(vis[i]==0) 26 { 27 prime[++tot]=i; 28 for(LL j=i;j<=15000;j+=i) 29 vis[j]=1; 30 } 31 } 32 // for(LL i=1;i<=tot;i++) 33 // cout<<prime[i]<<" "; 34 for(LL i=1;i<=n;i++) 35 { 36 LL p=i; 37 for(LL j=1;j<=tot;j++) 38 while(p%prime[j]==0&&p!=1) 39 ans[j]++,p=p/prime[j]; 40 } 41 for(LL i=1;i<=tot;i++) 42 if(ans[i]!=0) 43 printf("%lld %lld\n",prime[i],ans[i]); 44 return 0; 45 } View Code

T6P1737 曠野大計算

https://www.luogu.org/problemnew/show/P1737

?

轉載于:https://www.cnblogs.com/zwfymqz/p/7735029.html

總結

以上是生活随笔為你收集整理的2017.10.25水题大作战题解的全部內容,希望文章能夠幫你解決所遇到的問題。

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