链接:https://ac.nowcoder.com/acm/contest/908/C

题意:

Luffy once saw a particularly delicious food, but he didn't have the money, so he asked Nami for money. But we all know that Nami can't easily give money to Luffy. Therefore, Nami decided to take a test of Luffy. If Luffy was right, Nami would give him money, otherwise Luffy would only be hungry. The problem is as follows: Give you an 32-bit integer n and find the number of 1 in the binary representation of the integer.
You are the most trusted friend of Luffy, and he is now asking for help.

思路:

二进制找1,负数用1<<32 减一下就行。

代码:

#include <bits/stdc++.h>using namespace std;typedef long long LL;
const int MAXN = 3e5 + 10;
const int MOD = 1e9 + 7;
LL n, m, k, t;int main()
{cin >> t;while (t--){int sum = 0;cin >> n;if (n < 0)n = (1LL<<32)+n;while (n){if (n&1)sum++;n >>= 1;}cout << sum << endl;}return 0;
}

  

转载于:https://www.cnblogs.com/YDDDD/p/10960365.html

C.One Piece相关推荐

  1. vue 3.0 正式版_Vuejs 3 Release:One Piece. Vuejs 3.0 正式版发布!代号:海贼王

    Vuejs 3.0 在北京时间2020年9月19日凌晨,终于发布了 3.0 版本,代号:One Piece.此次vue3.0 为用户提供了全新的 composition-api 以及更小的包大小,和更 ...

  2. SpokenEnglish--It's a piece of cake

    一,Ask for help(12-24) A:Jim,Could you do me a faver? B:Sure ,just ask ,what can I do for you? A:My c ...

  3. AbiWord 中Piece Table 数据结构的实现----AbiWord Documentation

    AbiWord Documentation[转] Introduction One of the major bits of AbiWord word processing code is the P ...

  4. Oracle问题处理——MAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece

    问题描述 通过rman进行异机恢复参数文件时,提示如下错误: RMAN> restore spfile from autobackup;Starting restore at 16-AUG-14 ...

  5. 碗状碎块三维模型的下载(.PLY格式)3D model file with Bowl-shaped Broken Piece (.ply format)

    碗状碎块三维模型的下载(.PLY格式) 3D model file with Bowl-shaped Broken Piece (.ply format) 上传的碗状碎块共有两组,这些碎块在断裂曲面处 ...

  6. 淘宝神话-one piece 般的十年

    引用著名日本人气漫画<one piece>里男主角之一 Monkey D Ruffy 说的一句很经典的话--"我是要成为海贼王的男人". 当我在试读<淘宝技术这十 ...

  7. One Piece 海贼王动漫壁纸 Python 爬取!

    我知道没有图片你们是不会看下去的... 日本文化输出非常厉害,比如说动漫,火影忍者的完整让不少人都感叹:"爷青结",当然还有入土都难以完结的动漫,比如名侦探河南,不对,手抖了,柯南 ...

  8. One Piece!

    1 Op人物的藏头秘密(也代表八种人生观) Overcome myself--克服自己 Navigate the reticent companion--航行中无言的同伴 Eager for the ...

  9. java游戏实战chess-3.Piece类之knight

    一.Piece类 Piece代表棋子类,每一枚棋子都有对应的位置坐标和对应的阵营(Alliance)(黑子或者白子). 我们需要限制棋子的移动位置,限制因素有很多,比如它所属阵营,它的本身属性,移动的 ...

  10. A Piece Of My Heart

    清纯干净面貌的美丽唱片,就等你抛开恼人工作以愉悦心情欣赏 艺人名称:Jazzamor (爵士情人乐团) 专辑名称:A Piece Of My Heart (心之彼方) 发行日期:2004年5月 相关资 ...

最新文章

  1. mySQL笔记(1)
  2. vs code 列编辑模式
  3. 接到三无产品的测试需求时怎么办
  4. Shell命令-文件及内容处理之more、less
  5. 将字符串分解成一个表(多行、多列)表值函数[ StrSplit_Tab]
  6. 基本概念之运算符与表达式
  7. python打开figure对象_Python ——绘图 plt.figure()的使用
  8. 【竞赛总结】传染病的传播趋势预测
  9. 多线程之继承Thread类及多线程内存分析
  10. 深入理解this机制系列第三篇——箭头函数
  11. 包体 400 KB,首开 0.2 s,真有这样的播放器 SDK!
  12. div自定义下拉框组件
  13. sqlserver字符串拼接
  14. Python——球面两点距离及两条直线夹角的计算
  15. 滤芯怎么换 石头机器人_拆开看个究竟,石头扫拖一体机器人T6到底如何?
  16. win10专业版和企业版的区别
  17. 网络层—简单的arp断网
  18. android竖屏固定,安卓教程:设置竖屏固定壁纸
  19. [SCUCTF2022]校赛Web出题笔记
  20. 42个5G智慧教育应用场景,告诉你5G将如何改变教育

热门文章

  1. 【BZOJ】【1015】 【JSOI2008】星球大战starwar
  2. linux 内核学习线索初步
  3. 小白设计模式:访问者模式
  4. Netty工作笔记0081---编解码器和处理器链梳理
  5. Netty工作笔记0056---Unpooled应用实例2
  6. IOS工作笔记002---windows给VmWare虚拟机OS系统安装VMTools
  7. Ui学习笔记---EasyUI的介绍
  8. 运行 lighttrack 遇到错误和解决方法
  9. DPM 检测源码分析
  10. torch将多个tensor张量合并为一个张量,只提高迷你批次的纬度