#include992 插队using namespace std; const int N = 109; int n, a[N]; int main() { cin >> n; for (int i = 1; i <= n; i ++) cin >> a[i]; cin >> a[++n]; int k = n; while (a[k] > a[k-1] && k >= 2) { swap(a[k], a[k-1]); k --; } for (int i = 1; i <= n; i ++) cout << a[i] << ' '; return 0; }
#include993 删除数组中重复的数using namespace std; const int N = 109; int n, x, a[N]; int main() { cin >> n; for (int i = 1; i <= n; i ++) { cin >> a[i]; if (a[i] + a[i-1] > 350) { cout << 50 << ' '; } cout << a[i] << ' '; } return 0; }
#include994 删除倍数using namespace std; int n, x; set s; set :: iterator it; int main() { cin >> n; for (int i = 1; i <= n; i ++) { cin >> x; s.insert(x); } for (it = s.begin(); it != s.end(); it ++) cout << *it << ' '; return 0; }
#include995 第K个点using namespace std; const int N = 109; int n, x, a[N]; int main() { cin >> n >> x; for (int i = 1; i <= n; i ++) { cin >> a[i]; if (a[i] % x != 0) { cout << a[i] << ' '; } } return 0; }
#include996 前缀和using namespace std; const int N = 1009; int n, k, x; set s; set :: iterator it; int main() { cin >> n >> k; for (int i = 1; i <= n; i ++) { cin >> x; s.insert(x); } it = s.begin(); for (int i = 1; i < k; i ++) it ++; cout << *it << endl; return 0; }
#include997 前缀和的逆using namespace std; const int N = 109; int n, a[N], b[N]; int main() { cin >> n; for (int i = 1; i <= n; i ++) { cin >> a[i]; b[i] = b[i-1] + a[i]; cout << b[i] << ' '; } return 0; }
#include998 新数列using namespace std; const int N = 109; int n, a[N], b[N]; int main() { cin >> n; for (int i = 1; i <= n; i ++) { cin >> b[i]; a[i] = b[i] - b[i-1]; cout << a[i] << ' '; } return 0; }
#include999 多次求一段和using namespace std; const int N = 109; int n, a[N], b[N]; int main() { cin >> n; for (int i = 1; i <= n; i ++) cin >> a[i]; for (int i = 1; i <= n; i ++) { if (i == 1 || i == n) cout << a[i] << ' '; else cout << a[i-1] + a[i] + a[i+1] << ' '; } return 0; }
#include1000 11的倍数using namespace std; const int N = 1e5 + 10; int n, m, a[N], s[N]; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i ++) { scanf("%d", &a[i]); s[i] = s[i-1] + a[i]; } while (m --) { int x, y; scanf("%d%d", &x, &y); if (x > y) swap(x, y); printf("%dn", s[y] - s[x - 1]); } return 0; }
#include1001鸡蛋using namespace std; const int N = 1e5 + 10; int n, m, a[N], s[N]; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i ++) { scanf("%d", &a[i]); s[i] = s[i-1] + a[i]; } while (m --) { int x, y; scanf("%d%d", &x, &y); if (x > y) swap(x, y); int t = s[y] - s[x - 1]; if (t % 11 == 0) puts("1"); else puts("0"); } return 0; }
#includeusing namespace std; const int N = 1e5 + 10; int n, a[N], s[N], h[7]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i ++) { scanf("%d", &a[i]); s[i] = s[i-1] + a[i]; h[s[i] % 7] ++; } long long ans = h[0]; for (int i = 0; i < 7; i ++) { ans += h[i] * (h[i] - 1) / 2; } cout << ans; return 0; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)