官方題解:http://www.jnxxhzz.com/Article/article/9.html
2019: 特產
Time Limit: 1 Sec??Memory Limit: 128 MBSubmit: 548??Solved: 154
[Submit][Status][Web Board]
Description
?
Input
?
Output
?輸出一個整數表示dd帶回來的特產重量
?
Sample Input
2 3 6 1 3
Sample Output
3 2?
【分析】:注意是實數,不要用cin會超時。
【代碼】: 
View Code
Submit: 591??Solved: 141
[Submit][Status][Web Board]


#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; }
?
2020: Pizza
Time Limit: 1 Sec??Memory Limit: 128 MBSubmit: 591??Solved: 141
[Submit][Status][Web Board]
Description
?
Input
?
Output
輸出cc最少會獲得的卡路里
?
Sample Input
1 1 2
Sample Output
2
HINT
【分析】:最少那就只吃一塊pizza。
【代碼】: 
View Code
Submit: 330??Solved: 115
[Submit][Status][Web Board]


#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; }
?
不忘初心,砥礪前行!
2024: cc的神奇背包
Time Limit: 1 Sec??Memory Limit: 128 MBSubmit: 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?
【分析】:結構體排序。
【代碼】:有注釋。 
結構體排序
Submit: 147??Solved: 26
[Submit][Status][Web Board]


#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 MBSubmit: 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多的個數 。

思維
Submit: 68??Solved: 23
[Submit][Status][Web Board]

【代碼】:


#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 MBSubmit: 68??Solved: 23
[Submit][Status][Web Board]
Description
?
Input
?
Output
?
Sample Input
1 4
Sample Output
11?
【分析】:藍橋杯原題改編了一點。 
DFS
Submit: 519??Solved: 59
[Submit][Status][Web Board]
第八屆 藍橋杯 方格分割
【代碼】:


#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; }
?
2014: 一生之敵
Time Limit: 1 Sec??Memory Limit: 128 MBSubmit: 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]);} }
?