- 博客(4)
- 收藏
- 关注
原创 __builtin_popcount(x)
__builtin_popcount(x) GCC提供的内建函数,主要作用是将x表示成二进制时有多少个1(32位). 例如: int x = 7; // 7 = 111; int n = __builtin_popcount(x); //n = 3;
2020-11-06 17:03:49 389
原创 PTA最大子列和问题
给定K个整数组成的序列{ N1, N2, …, NK },“连续子列”被定义为{ Ni, Ni+1, …, Nj },其中 1≤i≤j≤K。“最大子列和”则被定义为所有连续子列元素的和中最大者。例如给定序列{ -2, 11, -4, 13, -5, -2 },其连续子列{ 11, -4, 13 }有最大的和20。现要求你编写程序,计算给定整数序列的最大子列和。
2018-01-17 15:35:46 326
原创 The Blocks Problem UVA - 101
第一次用vector。。。 代码:#include <iostream> #include <cstdio> #include <string> #include <vector> #include <algorithm> const int maxn = 30; using namespace std; vector<int> pile[maxn];//每个pile[i]都是一个vector i
2017-03-30 22:49:32 165
原创 Where is the Marble? UVA - 10474
题意:有n个大理石,每个大理石上写了一个非负整数,首先把各数从小到大排序,然后回答q个问题,每个问题问是否有一个大理石上写着某个整数x,如果是,还要回答那个大理石上写着x。#include <iostream> #include <cstdio> #include <algorithm> const int maxn = 10005; using namespace std;int main() {
2017-03-28 18:09:19 180
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人