随笔分类 - C++编程错题整理
摘要:include<bits/stdc++.h> using namespace std; int h[100005],m[100005],a[100005]; int main(){ int n,H,M; cin>>n>>H>>M; a[0]=H60+M; for(int i=1;i<=n;i++){
阅读全文
摘要:include <bits/stdc++.h> using namespace std; long long cnt[100010]; // cnt[i]代表质因数i的幂次 int main() { int n; cin>>n; for(int i=1; i<=n; i++){ cnt[i]=0;
阅读全文
摘要:include <bits/stdc++.h> using namespace std; int main() { int t; cin>>t; int c; cin>>c; int sum=0; long long ans=0; for (int i=1; i<=t; i++) { int x;
阅读全文
摘要:include <bits/stdc++.h> using namespace std; long long t, m; int main( ) { cin >> t >> m; if (t<=m) { cout << (m-t)/2+1; } else { cout << 0; } return
阅读全文
摘要:include <bits/stdc++.h> using namespace std; int maxx, a, b, c; int main( ) { cin >> a; b=10; c=3; while(b!=a) { if (c1||c2) { b+=7; } b--; c++; c%=7;
阅读全文
摘要:include <bits/stdc++.h> using namespace std; int n, m, k, a[1000005], b[1000005], sum, t, l, r, mid; int main( ) { cin >> n >> m >> k; for (int i=1;i<
阅读全文
摘要:这个是具体的代码,孩子的代码问题在子矩阵的判断有问题。 就是这几行,没有具体实现。 原思路代码块 include <bits/stdc++.h> using namespace std; int n, a, b, m[105][105]; int main() { cin >> n; for (in
阅读全文
摘要:2133: 练4.4 牛吃牧草 2132: 练4.3 3个连续数 一本通1068:与指定数字相同的数的个数 【printf和scanf的非常正常用法】 一本通 1071:菲波那契数 一本通 1069:乘方计算 2146: 【例7.2】与圆相关的计算 2153: 【例8.3】计算球的体积 球的体积公式
阅读全文
摘要:include <bits/stdc++.h> using namespace std; int n, m; long long sum=1, k; int main( ) { cin >> n >> m >> k; for (int i=1;i<=k;i++) { n*=10; sum=n/m;
阅读全文
摘要:include <bits/stdc++.h> using namespace std; int n; double e=1, cj=1; int main( ) { cin >> n; for (int i=1;i<=n;i++) { cj*=i; e+=e+1/cj; } cout << fix
阅读全文
摘要:include <bits/stdc++.h> using namespace std; int n, m, sum, num; int main( ) { cin >> n >> m; for (int i=1;i<=n;i++) { int e; cin >> e; if (num+e>m) {
阅读全文
摘要:https://oj.hetao101.com/d/contest_past/p/2069?tid=67076fb1c7a03d8a4628b276 这个思路错了,怎么还给排序上了。 正确解题 这个是不涉及字符串操作的。 这个是第二种做法,会涉及函数操作。 原错误的代码 include <bits/
阅读全文
摘要:所以要从题目出发,优化代码 思路是: 1、前缀和,算出来累加和。 2、通过tot*2==sum,判断是不是有相等的值。 这个是数学上的优化。 原错误的代码思路 include <bits/stdc++.h> using namespace std; int n; int main( ) { cin
阅读全文
摘要:include <bits/stdc++.h> using namespace std; int main( ) { int n=2, m; cin >> m; double sum=1; while (sum<m) { sum+=1*1.0/n; n++; } cout << n-1; retur
阅读全文
摘要:include <bits/stdc++.h> using namespace std; int n, a, sum; int main( ) { cin >> n; for (int i=1;i<=n;i++) { cin >> a; sum+=a; } cout << sum << " "; c
阅读全文
摘要:include <bits/stdc++.h> using namespace std; int main( ) { char a; cin >> a; cout << " " << a << endl; cout << " " << a << a << a << endl; cout << a <
阅读全文
摘要:include <bits/stdc++.h> using namespace std; int main( ) { char a; cin >> a; cout << char(a-32); return 0; } // 反思1: cin >> a; 忘记写了 反思2: +是转为小写字母-是转为大
阅读全文
摘要:include <bits/stdc++.h> using namespace std; int n; int main( ) { cin >> n; cout << n/100 << endl; n=n%100; cout << n/50 << endl; n=n%50; cout << n/20
阅读全文
摘要:include <bits/stdc++.h> using namespace std; double z, c, p; int main( ) { cin >> z >> c >> p; cout << z/10020+c/10030+p/100*50; return 0; } 反思:设定的代码块
阅读全文
摘要:include <bits/stdc++.h> using namespace std; double r, pi=3.14; int main( ) { cin >> r; cout << fixed << setprecision(2)<< 4.0/3.0pirrr; return 0; } 球
阅读全文