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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

浙江中医药大学第十一届程序设计竞赛题解

發布時間:2023/12/10 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 浙江中医药大学第十一届程序设计竞赛题解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

官方題解:http://www.jnxxhzz.com/Article/article/9.html

2019: 特產

Time Limit: 1 Sec??Memory Limit: 128 MB
Submit: 548??Solved: 154
[Submit][Status][Web Board]

Description

?

Input


?

Output

?輸出一個整數表示dd帶回來的特產重量

?

Sample Input

2 3 6 1 3

Sample Output

3 2? 【分析】:注意是實數,不要用cin會超時。 【代碼】: #include <bits/stdc++.h>using namespace std; #define ll long long #define PI 3.14159 int t; int main() {scanf("%d",&t);while(t--){double n,m;scanf("%lf%lf",&n,&m);printf("%.0f\n",(m-n));}return 0; } View Code

?


2020: Pizza

Time Limit: 1 Sec??Memory Limit: 128 MB
Submit: 591??Solved: 141
[Submit][Status][Web Board]

Description

?

Input

?

Output

輸出cc最少會獲得的卡路里

?

Sample Input

1 1 2

Sample Output

2

HINT

【分析】:最少那就只吃一塊pizza。 【代碼】: #include <bits/stdc++.h>using namespace std; #define ll long long #define PI 3.14159 int t; int n; double k; int main() {scanf("%d",&t);while(t--){scanf("%d%lf",&n,&k);printf("%.0f\n",1.0*k);}return 0; } View Code

?

不忘初心,砥礪前行!

2024: cc的神奇背包

Time Limit: 1 Sec??Memory Limit: 128 MB
Submit: 330??Solved: 115
[Submit][Status][Web Board]

Description

?

Input

?

Output

?

Sample Input

1 4 2 1 2 2 1 3 1 2 3

Sample Output

yes? 【分析】:結構體排序。 【代碼】:有注釋。 #include <bits/stdc++.h>using namespace std; #define ll long long #define PI 3.14159 int t; int n,k; struct node {int x,y; }a[5000]; //int a[5000],b[5000]; int cmp(node a,node b) {return a.x<b.x; //體積小的先放return a.y>b.y; //擴容大的先放 } int f=1; int main() {scanf("%d",&t);while(t--){f=1;scanf("%d%d",&n,&k);for(int i=0;i<n;i++){scanf("%d%d",&a[i].x,&a[i].y);}sort(a,a+n,cmp);for(int i=0;i<n;i++){if(a[i].x>k||k<0){f=0;}else{k=k-a[i].x+a[i].y;}}if(f) puts("yes");else puts("no");}return 0; }/* n v //n個禮物 體積為v的背包 ai bi //每個禮物的體積ai 背包對這件禮物的喜愛程度bi(物體放到背包會擴大的體積) 能不能所有禮物都放到背包 【初始體積k=2】 1 2 k= 2-1+2=3 2 3 k= 3-2+3=4 2 1 k= 4-2+1=3 3 1 k= 3-3+1=1 a升序 b降序 */ 結構體排序

?


2017: 開心的cc

Time Limit: 1 Sec??Memory Limit: 128 MB
Submit: 147??Solved: 26
[Submit][Status][Web Board]

Description

?

Input

?

Output

?

Sample Input

2 5 1 0 1 1 0 5 1 1 1 1 1

Sample Output

1 5

HINT

?

【分析】:?直接看?1比0多的個數 。

【代碼】:

#include <bits/stdc++.h>using namespace std; int t; int n,x,cnt; int main() {scanf("%d",&t);while(t--){cnt=0;scanf("%d",&n);for(int i=0;i<n;i++){scanf("%d",&x);if(x==1) cnt++;else cnt--;}printf("%d\n",max(cnt,0));}return 0; } 思維

?


不忘初心,砥礪前行!

2021: 剪紙

Time Limit: 4 Sec??Memory Limit: 128 MB
Submit: 68??Solved: 23
[Submit][Status][Web Board]

Description

?

Input

?

Output

?

Sample Input

1 4

Sample Output

11? 【分析】:藍橋杯原題改編了一點。

第八屆 藍橋杯 方格分割

【代碼】:

#include <algorithm> #include <string.h> #include <iostream> #include <stdio.h> #include <string> #include <vector> #include <queue> #include <map> #include <set> using namespace std; using namespace std; int ans = 0; int mpt[20+1][20+1]; int N; int dir[4][2] = {0,1,1,0,0,-1,-1,0}; void dfs(int x,int y) {if(x == 0 || y == 0 || x == N || y == N){ans ++;return;}for(int i = 0 ; i < 4 ; i ++){int tx = x + dir[i][0];int ty = y + dir[i][1];if(mpt[tx][ty])continue;mpt[tx][ty] = 1;mpt[N-tx][N-ty] = 1;dfs(tx,ty);mpt[tx][ty] = 0;mpt[N-tx][N-ty] = 0;} } int main() {int pp;scanf("%d",&pp);while (pp--){scanf("%d",&N);ans=0;//注意多組數據置位memset(mpt,0,sizeof(mpt));mpt[N/2][N/2] = 1;dfs(N/2,N/2);printf("%d\n",ans/4);}return 0; } DFS

?


2014: 一生之敵

Time Limit: 1 Sec??Memory Limit: 128 MB
Submit: 519??Solved: 59
[Submit][Status][Web Board]

Description

?

Input

?第一行輸入一個整數T,表示數據組數。??
每組數據輸入一個整數n。

?1 <= T <= 100000?
?0 <= n <= 10^19
保證結果存在?

?

Output

?輸出一個整數。

?

Sample Input

3 2 6 100

Sample Output

6 6 114 【分析】:這道題實際上就是找2a為為完全平方數的時候,?然后把這些數存起來 ?(預處理),二分就行了 ,注意用ULL 【代碼】: #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsigned long long ULL; const int maxn = 1400000 + 10; ULL f[maxn]; void init() {for(int i=0;i<maxn;i++){f[i] = 4ull * i * i * i + 2ull * i;} }int main() {init();int t;scanf("%d",&t);while(t--){ULL n;scanf("%llu",&n);LL ans = lower_bound(f,f+maxn,n) - f;printf("%llu\n",f[ans]);} } 預處理+二分

?

轉載于:https://www.cnblogs.com/Roni-i/p/8022466.html

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的浙江中医药大学第十一届程序设计竞赛题解的全部內容,希望文章能夠幫你解決所遇到的問題。

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