几道纯模拟题没有写,暂且先放一下

P1428

小鱼比可爱

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;
typedef long long  ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int s[109];
int ans[109];
int main()
{ios;int n;cin>>n;for(int i = 1;i<=n;i++)cin>>s[i];for(int i = 1;i<=n;i++){int cnt = 0;for(int j = i-1;j>=1;j--){if(s[i]>s[j])cnt++;}ans[i] = cnt;}for(int i = 1;i<=n;i++)cout<<ans[i]<<' ';
}

P1427

小鱼的数字游戏

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;
typedef long long  ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int s[109];
int main()
{ios;int cnt = 0;while(1){int t;cin>>t;if(!t)break;s[++cnt] = t;}for(int i = cnt;i>=1;i--)cout<<s[i]<<" ";
}

P5727

【深基5.例3】冰雹猜想

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;
typedef long long  ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int s[109];
int main()
{ios;int n;cin>>n;int cnt = 0;int q = n;while(n!=1){if(n&1)n = n*3+1;elsen = n/2;s[++cnt] = n;}for(int i = cnt;i>=1;i--)cout<<s[i]<<" ";cout<<q<<"\n";
}

P1047

[NOIP2005 普及组] 校门外的树

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;
typedef long long  ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e4+9;
int s[N];
int main()
{ios;int n,m;cin>>n>>m;while(m--){int l,r;cin>>l>>r;s[l] --;s[r+1] ++;} int ans = 0;int q = 0;for(int i = 0;i<=n;i++){q += s[i];if(!q)ans++;}cout<<ans<<endl;
}

P5728

【深基5.例5】旗鼓相当的对手

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;
typedef long long  ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e4+9;
struct nn
{int a,b,c,sum;void add(){sum = a+b+c;}
}s[1009];
int main()
{int n;cin>>n;for(int i = 1;i<=n;i++){cin>>s[i].a>>s[i].b>>s[i].c;s[i].add();}int ans = 0;for(int i = 1;i<=n;i++){for(int j = i+1;j<=n;j++){if(abs(s[i].a-s[j].a)<=5&&abs(s[i].b-s[j].b)<=5&&abs(s[i].c-s[j].c)<=5&&abs(s[i].sum-s[j].sum)<=10)ans++;}}    cout<<ans<<"\n";
}

P5729

【深基5.例7】工艺品制作

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;
typedef long long  ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e4+9;
bool s[25][25][25];
int main()
{ios;int a,b,c;cin>>a>>b>>c;int t;cin>>t;while(t--){int x,y,z;int x2,y2,z2;cin>>x>>y>>z>>x2>>y2>>z2;for(int i = x;i<=x2;i++)for(int j = y;j<=y2;j++)for(int k = z;k<=z2;k++)s[i][j][k] = 1;}int ans = 0;for(int i = 1;i<=a;i++)for(int j = 1;j<=b;j++)for(int k = 1;k<=c;k++)if(!s[i][j][k])ans++;cout<<ans<<"\n";
}

P2550

[AHOI2001]彩票摇奖

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;
typedef long long  ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e4+9;
int ans[10];
int main()
{ios;int n;cin>>n;int s[10];cin>>s[1]>>s[2]>>s[3]>>s[4]>>s[5]>>s[6]>>s[7];while(n--){int cnt = 0;int q[10];cin>>q[1]>>q[2]>>q[3]>>q[4]>>q[5]>>q[6]>>q[7];for(int i = 1;i<=7;i++){for(int j = 1;j<=7;j++){if(s[i]==q[j])cnt++;}}ans[cnt]++;}for(int i = 7;i>=1;i--)cout<<ans[i]<<' ';
}

P1554

梦中的统计

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;
typedef long long  ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int s[10];
int main()
{ios;int l,r;cin>>l>>r;for(int i = l;i<=r;i++){int t = i;while(t){s[t%10]++;t/=10;}}for(int i = 0;i<=9;i++)cout<<s[i]<<' ';} 

P2141

[NOIP2014 普及组] 珠心算测验

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;
typedef long long  ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 2e4+9;
bool s[N];
int p[109];
int t[N];
int main()
{ios;int n;cin>>n;for(int i = 0;i<n;i++)cin>>p[i],s[p[i]] = 1;for(int i = 0;i<n-1;i++)for(int j = i+1;j<n;j++)t[p[i]+p[j]]++;int ans = 0;for(int i = 1;i<=20000;i++){if(s[i]&&t[i])ans++;}cout<<ans<<"\n";} 

P1614

爱与愁的心痛

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;
typedef long long  ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e4;
int s[N];
int main()
{ios;int n,m;cin>>n>>m;for(int i = 1;i<=n;i++)cin>>s[i];int t = 0;int mn = 0;for(int i = 1;i<=m;i++)mn+=s[i];t = mn;for(int i = m+1;i<=n;i++){t = t-s[i-m]+s[i];mn = min(mn,t);}cout<<mn<<"\n";} 

P2911

[USACO08OCT]Bovine Bones G

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;
typedef long long  ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 100;
int s[N];
int main()
{ios;int a,b,c;cin>>a>>b>>c;for(int i = 1;i<=a;i++)for(int j = 1;j<=b;j++)for(int k = 1;k<=c;k++)s[i+j+k]++;int mx = 0;int ans = 0;for(int i = 1;i<=N;i++){if(mx<s[i])mx = s[i],ans = i;}cout<<ans<<"\n";} 

P1161

开灯

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;
typedef long long  ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e7+5;
bool s[N];
int main()
{ios;int n;cin>>n;while(n--){int t;double a;cin>>a>>t;for(int i = 1;i<=t;i++){s[int(i*a)] = !s[int(i*a)];}}for(int i = 1;;i++){if(s[i]){cout<<i<<"\n";return 0;}}} 

P5732

【深基5.习7】杨辉三角

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;
typedef long long  ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 100;
int s[25][25];
int main()
{ios;int n;cin>>n;for(int i = 1;i<=n;i++){s[i][1] = 1,s[i][i] = 1;}for(int i = 3;i<=n;i++)for(int j = 2;j<=i-1;j++)s[i][j] = s[i-1][j]+s[i-1][j-1];for(int i = 1;i<=n;i++){for(int j = 1;j<=i;j++){cout<<s[i][j]<<' ';}cout<<"\n";}} 

P1789

【Mc生存】插火把

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;
typedef long long  ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 105;
bool s[N][N];
int n;
void hb(int x,int y)
{s[x][y] = 1;if(y-1>0)  s[x][y-1] = 1;if(y-2>0) s[x][y-2] = 1;if(y+1<=n)  s[x][y+1] = 1;if(y+2<=n) s[x][y+2] = 1;if(x-1>0)    s[x-1][y] = 1;if(x-2>0) s[x-2][y] = 1;if(x+1<=n)  s[x+1][y] = 1;if(x+2<=n) s[x+2][y] = 1;if(x-1>0&&y-1>0)  s[x-1][y-1] = 1;if(x+1<=n&&y+1<=n)   s[x+1][y+1] = 1;if(x-1>0&&y+1<=n)    s[x-1][y+1] = 1;if(x+1<=n&&y-1>0) s[x+1][y-1] = 1;
}
void ys(int x,int y)
{for(int i = x-2;i<=x+2;i++)for(int j = y-2;j<=y+2;j++){if(i>=1&&i<=n&&j>=1&&j<=n)s[i][j] = 1;}
}
int main()
{int m,k;cin>>n>>m>>k;for(int i = 1;i<=m;i++){int x,y;cin>>x>>y;hb(x,y);}for(int i = 1;i<=k;i++){int x,y;cin>>x>>y;ys(x,y);}int ans = 0;for(int i = 1;i<=n;i++)for(int j = 1;j<=n;j++){if(!s[i][j])  ans++;}cout<<ans<<"\n";
}

P1319

压缩技术

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;
typedef long long  ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e5;
bool s[N];
int main()
{int n;cin>>n;bool flag = 0;int cnt = 1; int t;while(cin>>t){if(!flag)for(int j = 1;j<=t;j++)s[cnt++] = 0;elsefor(int j = 1;j<=t;j++)s[cnt++] = 1;flag = !flag;}for(int i = 1;i<=cnt-1;i++){cout<<s[i];if(i%n==0)cout<<"\n";}
}

P1320

压缩技术(续集版)

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include <iomanip>
using namespace std;
typedef long long  ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e5;
char s[N];
int an[N];
int cnt = 0;
int main()
{int ans = 0;bool flag = 1;int n;bool q = 0;while(cin>>s){if(flag){n = strlen(s);flag = 0;}for(int i = 0;i<n;i++){if(s[i]=='0'&&q == 0){ans++;}else if(s[i]=='1'&&q == 0){an[++cnt] = ans;q = 1;ans = 1;}else if(s[i]=='1'&&q == 1){ans++;}else if(s[i]=='0'&&q == 1){an[++cnt] = ans;q = 0;ans = 1;}}memset(s,0,n);}cout<<n<<' ';for(int i = 1;i<=cnt;i++)cout<<an[i]<<' ';cout<<ans<<"\n";
}

【入门4】数组 (今天刷洛谷了嘛)相关推荐

  1. 【入门2】分支结构 (今天刷洛谷了嘛)

    [60天计划] 刷洛谷(题单广场) and Acwing算法基础课 P5710 [深基3.例2]数的性质 #include<iostream> #include<algorithm& ...

  2. 【入门1】顺序结构 (今天刷洛谷了嘛)

    [60天计划] 刷洛谷(题单广场) and Acwing算法基础课 P1001 A+B Problem #include<iostream> #include<algorithm&g ...

  3. 一个新手刷洛谷网的经历

    刷洛谷网也有一段时间了,但是一直进展不大,当我刷完新手前三关的时候,循环那关有道三连击的题目正是我在算法书上遇到的那道题,当时看着很烦,因为实在没有任何头绪,不过幸运的是洛谷网只要求每关作对三道题就可 ...

  4. 数组——询问学号(洛谷 P3156)

    题目选自洛谷P3156 非常简单的入门题目,目的在于初步了解可变长数组vector的使用 解题代码: #include<stdio.h> #include<iostream> ...

  5. (树状数组+逆元)洛谷P5142 区间方差

    洛谷P5142 区间方差 (^ w ^) 题目背景 出题人并没有能力写有趣的题面-- 题目描述 对于一个长度为n的序列a1,a2,a3⋯ana_1,a_2,a_3\cdots a_na1​,a2​,a ...

  6. 【入门6】函数与结构体(今天刷洛谷了嘛)

    P5735 [深基7.例1]距离函数 #include<iostream> #include<algorithm> #include<cstdio> #includ ...

  7. 【入门5】字符串(今天刷洛谷了嘛)

    几道纯模拟题没有写,暂且先放一下 P5733 [深基6.例1]自动修正 #include<iostream> #include<algorithm> #include<c ...

  8. c语言怎么将n个数字存入到数组中_洛谷 || 拼数(C语言)

    点击这里关注"程序员Bob" Success does not consist in never making mistakes but in never making the s ...

  9. 【动态规划1】动态规划的引入(今天刷洛谷了嘛)

    注: P4017 最大食物链计数 因为现在还不会拓扑排序,所以暂且放到以后去解决! P1216 [USACO1.5][IOI1994]数字三角形 Number Triangles #include&l ...

最新文章

  1. java设计模式-Builder创建者模式
  2. 计算机如何读懂“人话”?五分钟了解文本挖掘那些事儿
  3. autoreleasing的用法介绍:
  4. MongoDB在linux下的启动
  5. C# 8 新特性 - using 声明
  6. mysql bit php,Bit Web Server (PHP,MySQL,PMA) 安卓WEB服务器
  7. 无约束最优化(五) 最小二乘法问题的解法
  8. 【转】使用cocos2d-console工具转换脚本为字节码
  9. Windows server 2003设置IP安全策略批处理脚本
  10. 20145322何志威 Exp7 网络欺诈技术防范
  11. 李少白讲摄影-不放过一切光线 地坛书市新书首发圆满结束
  12. 揭秘:全球第一张云安全国际认证金牌得主
  13. 股票学习-量柱和k线-第一天
  14. Are you referring to request attributes outside of an actual web request
  15. Hibernate criterion 方法总结
  16. 基于matplotlib.animation和python的流数据动态监控原型
  17. 6个哄自己开心的小技巧
  18. 傅连仲主编的《计算机应用基础》,学生教学论文,关于计算机应用基础课程标准研读的必要性相关参考文献资料-免费论文范文...
  19. 翻译工作的重要性_为什么翻译平台很重要
  20. 在家用手机怎么赚钱?赚钱的秘密就在这里!

热门文章

  1. php 取字符串的数字,php提取字符串中的数字
  2. docker之阿里云centos 7.x 启动容器报错处理办法
  3. leaflet-webpack 入门开发系列三地图分屏对比(附源码下载)
  4. docker certbot 一键申请https证书、证书过期续订、续订成功自动重启服务
  5. chrome下载地址
  6. 【Python】WordCloud库的使用
  7. 【Python】绘制哆啦A梦
  8. linux bash命令_Linux命令-您应该知道的基本Bash命令行技巧
  9. centos 卸载python和yum之后的解决办法
  10. ASP.NET网站发布-允许更新此预编译站点