当前位置: 代码迷 >> 综合 >> HDU-5980 Find Small A
  详细解决方案

HDU-5980 Find Small A

热度:88   发布时间:2023-11-23 12:31:35.0

【HDU-5980 Find Small A 】
题意: 给定一个32位int数, 判断它的之中有多少个97.
分析: 一个32位的int可以表示成4个char位大小, 直接除256即可.

#include <iostream>
#include <cstdio>
using namespace std;int main () {int t, n;int res = 0;scanf ("%d", &t);while (t--) {scanf ("%d", &n);while (n) {if (n%256 == 97) res++;n /= 256;}}printf ("%d\n", res);return 0;
}
  相关解决方案