代码 #include <iostream> #include <cstdio> #include <string> #include <set> using namespace std; int main() { int n; string a; int tmp; set<int> st; cin>>n; for(int i=0;i<n;i++){ cin>>a; tmp=0; for(in
关键 二进制的算法 代码 #include <iostream> #include <cstdio> #include <string> using namespace std; int main() { string s; int cnt=0; int zcnt=0,ocnt=0; getline(cin,s,'\n'); for(int i=0;s[i]!=NULL;i++){ if(s[i]<='z'
#include<iostream> using namespace std; #include<string> //创建通讯录存储最多的人数 #define MAX 1000 //创建联系人结构体 struct Person { string name; int sex; int age; int phone; string adder; }; //创建通讯录结构体 struct Adressbook { struct Pers
一只小猴子一天摘了许多桃子,第一天吃了一半,然后忍不住又吃了一个;第二天又吃了一半,再加上一个;后面每天都是这样吃。到第10天的时候,小猴子发现只有一个桃子了。问小猴子第一天共摘了多少个桃子。 #include <iostream>using namespace std;int main() { int a=1; for(int
易错点 变量名要看清楚 操作数组要谨慎 代码 #include <iostream> #include <cstdio> #include <string> #include <iomanip> using namespace std; int main(){ int n; string s; cin>>n; int f=0; int f2; int cnt=0; float t=0; for(int i=0;i<n
c++另一种编程思想称为泛型编程,主要是利用的技术就是模板 c++提供两种模板机制:函数模板和类模板 函数模板作用: 建立一个通用函数,其函数的返回值类型和形参类型可以不具体指定,用一个虚拟的类型来代表 template<typename T> //template--声明创建模板 typename--表
题意很简单,就是给一个数组,找出有多少个对是x ^ y > x & y 首先这题cf味道很冲,感觉当个div2b不是问题,那么我们就来考虑下高位讨论 所以我们可以计算出来每个ai的高位是多少,然后等差数列求和一下就行,最后用总对数减掉高位相同的对数,就是我们要的答案 #include <bits/stdc++.h
A. Grass Field 解决代码: void solve() { int a, b, c, d; cin >> a >> b >>c >>d; int cnt = 0; cnt = a + b +c + d; if(cnt == 0) cout << 0 << endl; else if(cnt == 4) cout << 2 << endl; else cout << 1 &
P3375 这里字符串以 \(0\) 开始。 #include<bits/stdc++.h> using namespace std; #define f(i, a, b) for(int i = (a); i <= (b); i++) #define cl(i, n) i.clear(),i.resize(n); #define endl '\n' typedef long long ll; typedef unsigned long long ull; ty
【C++】学生管理系统 一道非常经典的C语言题目,用C++实现 题目如下: 输入功能:由键盘输入10个学生的学号、姓名、三科成绩,并计算出平均成绩和总成绩,然后将它存入文件stud.dat。 插入功能:按学号增加一个学生信息,并将其插入到stud.dat中。 排序功能,按要求对学生信息进行排序,分为按
问题 cnt=cnt+a[i]*(i+1)*(n-i); 此处容易溢出,因此必须用long double 注意点 cout的格式化输出,iomanip cout<<fixed<<setprecision(2)<<cnt; 代码 #include <iostream> #include <cstdio> #include <iomanip> using namespace std; long double a[100003]
完成了小学期的指定内容 #include<iostream>#include<math.h>#include <stdlib.h>using namespace std;class Dian {private: double x, y, z;public: void srzb();//输入xyz void qrzb();//输出刚才输入的坐标并确认 double getx() { return x; } double gety() { return y; } do
https://ac.nowcoder.com/acm/problem/23050 最大公约数的辗转相除法 点击查看代码 #include <bits/stdc++.h> using namespace std; #define int long long int gcd(int a,int b) { return b ? gcd(b,a%b) : a; } signed main() { ios::sync_with_stdio(false);
代码 #include <iostream>#include <cstdio>#include <map>using namespace std;int main(){ char c; map<char,int> mp; mp['P']=0; mp['A']=0; mp['T']=0; mp['e']=0; mp['s
900——1000 5道 A. Anti Light's Cell Guessing 题意大概是在一个行列确定的坐标系里,最少用几个点可以唯一确定一个点 思路就是判断行列的最小值是否为1,是1的话,最多一个点就可以确定,否则两个点即可。 注意:1*1的方格需要的点是0,故需要特判 解决代码: void solve() { int n, m; ci
https://codeforc.es/contest/1697/problem/C 因为规则中,两种字符串变换都与‘b’有关,所以我们根据b的位置来进行考虑; 先去掉所有的'b',如果两字符串不相等就“NO”; 否则通过‘b'在a,b串中的位置,如果posa>posb,那么他们之间如果出现'a'就说明不可能 如果posb<posa,那么他们之间如果
转载博客: https://blog.csdn.net/weixin_45697774/article/details/105563993?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-0-105563993-blog-106273675.pc_relevant_multi_platform_whitelistv1&spm=1001.2101.3001.4242
1.std是什么? std::是个名称空间标示符,C++标准库中的函数或者对象都是在命名空间,std中定义的,所以我们要使用标准库函数中的函数或对象来使用std来限定。 对象count是标准函数库所提供的对象,而标准库函数在名字空间中被指定为std,所以在使用cout的时候要加上std::,这样编译器就会明白
【Day4】一名菜鸟ACMer的暑假训练 CF构造题1200-1400 D. Districts Connection https://codeforces.com/problemset/problem/1433/D 1200 pair<帮派,编号>排序 第一个帮派的第一个成员连向不同帮派的所有成员, 第一个帮派的其他成员连向任意一个不同帮派的成员 #include <bits/std
链接:https://ac.nowcoder.com/acm/contest/24213/1008来源:牛客网 题目描述 如图,A 点有一个过河卒,需要走到目标 B 点。卒行走规则:可以向下、或者向右。同时在棋盘上的任一点有一个对方的马(如上图的C点),该马所在的点和所有跳跃一步可达的点称为对
#include<iostream>using namespace std; /* * * * * * * * * * ** * * * ** * * * * * * * * * * * * * **/ void starup(int n) { for (int i = 1; i <= n; i++) { for (int j = 0; j < n - i; j++) cout << "
#include<iostream>using namespace std;int main() { int *p; p = new int(100); if (p == NULL) { cout << "allocation failure" << endl; } else { cout << "p 的值为: "<<*p <&l
2.5.1 Conditional temary operator module top_module ( input [7:0] a, b, c, d, output [7:0] min);// wire [7:0]r1,r2; //记得定义位宽 assign r1=(a<b)?a:b; assign r2=(c<d)?c:d; assign min=(r1<r2)?r1:r2;endmodule 2.5.2 Reduction operat
比赛链接: https://codeforces.com/contest/1698 C. 3SUM Closure 题意: 给定一个序列 \(a\),判断对于任意一个 \(1 <= i < j < k <= n\),是否存在一个 \(1 <= l <= n\),使得 \(a[i] + a[j] + a[k] = a[l]\)。 思路: 首先如果有三个正数及以上的正数,那么选择其中最大的三个,它们的和肯定
1-stl介绍_题解 2022/7/4-ACM暑期集训 A,最大或位_位运算贪心 题目大意 中文题自己看 思路和代码 要xy的或值最大则尽量让每一位或的结果都是1。考虑将y固定在r,x从l一点点变大。所以我们要让x在不大于r的情况下尽可能大。从大往小考虑二进制位。一旦出现“1<->0”的情况就表示后面